7/31/2019 Operating System Concepts Lecture 1
1/43
Operating System Concepts
By
Dr. Freddie Acosta9th May 2011
7/31/2019 Operating System Concepts Lecture 1
2/43
Definition
An operating system is a suite of program
which takes control over the operation of
the computer. An OS can be viewed as a resource
allocator.
7/31/2019 Operating System Concepts Lecture 1
3/43
The Computer System
Applications Programs
Hardware
Operating System Users
7/31/2019 Operating System Concepts Lecture 1
4/43
The Hardware
Provides the basic computing resources.
The Central Processing Unit (CPU)
MemoryI/O devices
7/31/2019 Operating System Concepts Lecture 1
5/43
Application Programs
Define the ways in which these resources
are used to solve the computing problems
of the users.Compilers
Database Systems
Games
Business programs
7/31/2019 Operating System Concepts Lecture 1
6/43
Users
People
Machines
Other computers
7/31/2019 Operating System Concepts Lecture 1
7/43
The Purpose of OS
To make the computer to operate in a
convenient and efficient manner.
To allow/process as many jobs as possiblein a given period of time.
7/31/2019 Operating System Concepts Lecture 1
8/43
OS Services
Program Execution
The system must be able to load a program
into memory and to run it. The program must
be able to end its execution, either normally or
abnormally (indicating error).
7/31/2019 Operating System Concepts Lecture 1
9/43
Services - Cont.
I/O Operations
A running program may require I/O. This I/O
may involve a file or an I/O device. For
specific devices, special functions may be
desired.
7/31/2019 Operating System Concepts Lecture 1
10/43
Servicescont.
File System manipulations
The file system is of particular interest. It
should be obvious that programs need to read
and write files. They also need to create and
delete files by name.
7/31/2019 Operating System Concepts Lecture 1
11/43
Servicescont.
Communications
between processes executing on the same
computer; between processes executing on
different computer systems that are tied
together by a computer network.
7/31/2019 Operating System Concepts Lecture 1
12/43
7/31/2019 Operating System Concepts Lecture 1
13/43
Servicescont.
Resource Allocation
CPU times, memory and file storage, I/O
devices etc must be allocated when there are
multiple users or multiple jobs running at the
same time.
7/31/2019 Operating System Concepts Lecture 1
14/43
Servicescont.
Accounting
To keep track of which users use how much
and what kinds of computer resources.
7/31/2019 Operating System Concepts Lecture 1
15/43
Servicescont.
Protection
Involves ensuring that all access to system
resources is controlled.
Security of the system outsiders is also
important through authentication.
7/31/2019 Operating System Concepts Lecture 1
16/43
Process Management
A process can be thought of as a program
in execution.
A process will need certain resourcessuch as CPU time, memory, files and I/O
devicesto accomplish its tasks.
7/31/2019 Operating System Concepts Lecture 1
17/43
Process State
New : the process is being created
Running: Instructions are being executed
Waiting: the process is waiting for someevent to occur (I/O completion)
Ready: the process is waiting to beassigned to a processor
Terminated: the process has finishedexecution
7/31/2019 Operating System Concepts Lecture 1
18/43
Process Scheduling
The purpose of multiprogramming is to
have some process running at all times, to
maximize CPU utilization. The objective of time sharing is to switch
the CPU among processes so frequently
that users can interact with each program
while it is running.
7/31/2019 Operating System Concepts Lecture 1
19/43
Context Switch
Switching the CPU to another process
requires saving the state of the old process
and loading the save state for the newprocess.
This task is known as context switch.
7/31/2019 Operating System Concepts Lecture 1
20/43
CPU Scheduling
Scheduling is a fundamental OS function.
The idea of multiprogramming is that, a
process is executed until it must wait. With multiprogramming, we try to use this
idle time productively.
7/31/2019 Operating System Concepts Lecture 1
21/43
eria
CPU Utilization
We want the CPU as busy as possible.
For lightly loaded system, it should be about40 percent.
For heavily loaded system, it should be about
90 percent.
7/31/2019 Operating System Concepts Lecture 1
22/43
Criteriacont.
Throughput
If the CPU is busy, then work is being done.
One measure of work is the number of
processes that are completed per time unit.
7/31/2019 Operating System Concepts Lecture 1
23/43
Criteriacont.
Turn Around Time
The interval from the time of submission to
the time of completion is the TAT.
TAT is the sum of the periods spent waiting to
get into memory, waiting in the ready queue,
executing on the CPU, and doing I/O.
7/31/2019 Operating System Concepts Lecture 1
24/43
Criteriacont.
Waiting Time
CPU scheduling algorithm does not affect the
amount of time during which a process
executes or does I/O;
It affects only the amount of time that a
process spends waiting in the ready queue
Waiting time is the sum of the periods spentwaiting in the ready queue.
7/31/2019 Operating System Concepts Lecture 1
25/43
Criteriacont.
Response Time
It is the amount of time it takes to start
responding, but not the time that it takes to
output that response.
7/31/2019 Operating System Concepts Lecture 1
26/43
Scheduling Algorithms
Non-Preemptive
Once CPU is allocated, it cant be taken back.
The process has to voluntarily release the
CPU.
Preemptive
The CPU can be taken away from a process if
a process with higher priority has arrived or
after a time quantum.
7/31/2019 Operating System Concepts Lecture 1
27/43
FCFS
The process that requests the CPU first is
allocated the CPU first.
When the CPU is free, it is allocated to theprocess at the head of the queue.
The Convoy Effect
7/31/2019 Operating System Concepts Lecture 1
28/43
Example
Job No CPU Burst
Time
Arrival Time
1 24 0
2 3 0
3 3 0
7/31/2019 Operating System Concepts Lecture 1
29/43
SJF
When the CPU is available, it is assigned
to the process that has the smallest next
CPU burst.
If two processes have the same length next
CPU burst, FCFS scheduling is used to
break the tie.
7/31/2019 Operating System Concepts Lecture 1
30/43
Example
Job No CPU Burst
Time
Arrival Time
1 6 0
2 8 0
3 7 0
4 3 0
7/31/2019 Operating System Concepts Lecture 1
31/43
Priority
The SJF is a special case of the general
priority scheduling algorithm.
Where the priority (p) is the inverse of thenext CPU burst (t): p = 1/t.
The larger the CPU burst, the lower the
priority, and vice versa.
7/31/2019 Operating System Concepts Lecture 1
32/43
Priorities
Internal Time limits
Memory requirements
The number of open files
Ratio of I/O Burst with CPU burst
External Importance of the process
Type and amount of funds being paid for computer
use, The department sponsoring the work
Political
7/31/2019 Operating System Concepts Lecture 1
33/43
Example
Process Burst Time/
Arrival Time
Priority
1 10/0 3
2 1/1 1
3 2/2 3
4 1/3 4
5 5/4 2
7/31/2019 Operating System Concepts Lecture 1
34/43
SRTF (Preemptive Algorithm)
Process AT BT
1 0 8
2 1 4
3 2 9
4 3 5
7/31/2019 Operating System Concepts Lecture 1
35/43
Problem with SRTF
Indefinite blocking or starvation
7/31/2019 Operating System Concepts Lecture 1
36/43
Round Robin
Was designed for time sharing.
It is similar to FCFS but preemption is
added to switch between processes. A small unit of time, called time quantum
(q) time slice, is defined. A q is generally
from 10 to 100 ms.
7/31/2019 Operating System Concepts Lecture 1
37/43
Example (q=4)
Process CPU AT
1 24 0
2 3 0
3 3 0
7/31/2019 Operating System Concepts Lecture 1
38/43
RR
If q positive infinity (very large), the
algorithm results to FCFS.
If q 0 (very small), RR approach is called
processor sharing and appears to the user as
though each n processes has its own processor
running at 1/n the speed of the real processor.
Rule of thumb, 80% of the CPU burst is lowerthan q.
7/31/2019 Operating System Concepts Lecture 1
39/43
Multi Level Queue
Partitions the ready queue into several
separate queues.
The processes are assigned permanently toa queue based on some properties such as
memory size, priority, process type.
Each queue has its own schedulingalgorithm.
7/31/2019 Operating System Concepts Lecture 1
40/43
Example 1
System Process
Interactive Processes
Interactive Editing processes
Batch processes
Student processes
Highest priority
Lowest priority
7/31/2019 Operating System Concepts Lecture 1
41/43
Example 2
System Process
Student processes
High Priority
Low Priority
80% of CPU Time
20% of CPU TIme
7/31/2019 Operating System Concepts Lecture 1
42/43
Multi Level Feedback Queue
Q = 8
Q = 16
FCFS
7/31/2019 Operating System Concepts Lecture 1
43/43
Algorithm Evaluation
FCFS, SJF, RR (q=10)
Process CPU BT AT
1 10 02 29 0
3 3 0
4 7 05 12 0
Solve for Average TAT and Average WT.