Professional Documents
Culture Documents
18IT502_U2_LM5_22-23
18IT502_U2_LM5_22-23
• CPU burst
• I/O burst
• Scheduling
• Long Term scheduling
Evocation
CPU Scheduling
Objectives
• Non-Preemptive scheduling
• When a process enters the state of running the state of that
process is not deleted from the scheduler until it finishes .
Dispatcher
• Dispatcher module gives control of the CPU to the process
selected by the short-term scheduler; this involves:
– switching context
– switching to user mode
– jumping to the proper location in the user program to
restart that program
• Dispatch latency – time it takes for the dispatcher to stop one
process and start another running
Scheduling Criteria
Gantt chart
P1 P2 P3 P1
0 2 8 11 14
Waiting time = (0-0)+(11-2)+(2-2) +(8-3)
= 9+5
=14/3=4.66ms
Non-preemptive
P1 P2 p3
0 5 11 14
• Average waiting time =0+3+8=11/3=3.66ms
• Average turnaround time = 5+9+11=25/3=8.33ms
Round Robin
• Designed for time sharing system
• It is similar to FCFS scheduling, but preemption is added to
switch between processes.
• A small unit of time, called a time quantum or time slice, is
defined. A time quantum is generally from 10 to 100
milliseconds.
• To implement RR scheduling, we keep the ready queue as a
FIFO queue of processes.
• If there are n processes in the ready queue and the time
quantum is q, then each process gets 1/n of the CPU time in
chunks of at most q time units at once. No process waits more
than (n-1)q time units.
An operating system uses the Shortest Remaining Time first
(SRTF) process scheduling algorithm. Consider the arrival times
and execution times for the following processes:
Process Execution time Arrival time
P1 20 0
P2 25 15
P3 10 30
P4 15 45
What is the total waiting time for process P2?
(A) 5
(B) 15
(C) 40
(D) 55
Consider the following table of arrival time and burst time for
three processes P0, P1 and P2. (GATE-CS-2011)
Process Arrival time Burst Time
P0 0 ms 9 ms
P1 1 ms 4 ms
P2 2 ms 9 ms
The pre-emptive shortest job first scheduling algorithm is used.
Scheduling is carried out only at arrival or completion of
processes. What is the average waiting time for the three
processes?
(A) 5.0 ms
(B) 4.33 ms
(C) 6.33
(D) 7.33
Mind Map
Summary
• Discussion