Professional Documents
Culture Documents
Unit 4 OSY Presentation
Unit 4 OSY Presentation
It is a process which allows one process to use the CPU while the execution of another process is
on hold(in waiting state) due to unavailability of any resource like I/O etc, thereby making full
use of CPU. The aim of CPU scheduling is to make the system efficient, fast and fair.
Scheduling Objectives :
1. Fairness : All the jobs should get fair chance to get use of CPU.
3. Response Time : A scheduler should minimize the response time for an interactive user.
4. Throughput : A scheduler should maximize the number of jobs processed per unit time.
CPU and I/O Bursts Cycle
CPU burst cycle : It is a time period when process is busy with
CPU.
I/O burst cycle : It is a time period when process is busy in
working with I/O resources.
5. Process switch from running to ready state Process switches from running to waiting state
6. Process switch from waiting to ready state Process terminates
For e.g.: Round Robin, Priority For e.g.: FCFS algorithm It is suitable
algorithms for RTS.
CPU Scheduling Criteria
CPU Utilization : In multiprogramming the main objective is to keep CPU as busy as
possible. CPU utilization can range from 0 to 100 percent.
Throughput : It is the number of processes that are completed per unit time.
Turnaround time :The time interval from the time of submission of a process to the
time of completion of that process is called as turnaround time. It is calculated as:
Turnaround Time = Waiting Time + Burst Time or End Time – Arrival Time
Waiting time : It is the sum of time periods spent in the ready queue by a process. It
is calculated as:
Waiting Time = Start Time – Arrival Time
Response time : The time period from the submission of a request until the first
response is produced is called as response time.
First-Come, First-Served (FCFS) Scheduling
Example :
First-Come, First-Served (FCFS) Scheduling
0 24 27 30
P2 P3 P1
0 3 6 30
FCFS
Gantt chart:
P1 P2 P3 P4 P5
0 7 11 21 27 35
P1 0 7 0-0=0
P2 1 4 7-1=6
P3 2 10 11-2=9
P4 3 6 21-3=18
P5 4 8 27-4=23
0 24 27 31
First-Come, First-Served (FCFS) Scheduling
Q1. Find the average waiting time & Turn around time uing FCFS algorithm
Q2. Find the average waiting time & Turn around time uing FCFS algorithm
0 3 9 16 24
P1 P2 P1 P4 P5 P3
0 1 5 11 17 25 35
0 1 5 10 17 26
P2 P5 P1 P3 P4
0 1 6 16 18 19
P1 5
P2 3
P3 1
P4 2
P5 3
Multilevel Queue
When a process gets all its resources it must return them in a finite amount of time
Data Structures for the Banker’s Algorithm
Algorithm F: Free resources
Step 1: When a process requests for a resource, the OS allocates it on a trial basis.
Step 2: After trial allocation, the OS updates all the matrices and vectors. This updating can be
done by the OS in a separate work area in the memory.
Step 3 : It compares F vector with each row of matrix B on a vector to vector basis.
Step 4 : If F is smaller than each of the row in Matrix B i.e. even if all free resources are
allocated to any process in Matrix B and not a single process can completes its task then
OS concludes that the system is in unstable state.
Step 5 : If F is greater than any row for a process in Matrix B the OS allocates all
required resources for that process on a trial basis. It assumes that after completion of
process, it will release all the recourses allocated to it. These resources can be added to
the free vector.
Step 6: After execution of a process, it removes the row indicating executed process from both
matrices.
Step 7: This algorithm will repeat the procedure step 3 for each process from the matrices and
finds that all processes can complete execution without entering unsafe state.
Resource-Request Algorithm for Process Pi
Need
ABC
P0 7 4 3
P1 1 2 2
P2 6 0 0
P3 0 1 1
P4 4 3 1
The system is in a safe state since the sequence < P1, P3, P4, P2, P0> satisfies
safety criteria
End
of Chapter 4