Page 86 - DCAP103_Principle of operating system
P. 86
Unit 3: Process Management-II
Notes
P1 P2 P3 P4
0 8 12 21 26
Average wait = ((8 – 0) + (12 –1) + (21 – 2) + 26 – 3))/4 = 61/4 = 15.25
Residence Time 5: CPU-Scheduling
at the CPU
For example, the time slot could be 100 milliseconds. If job1 takes a total
time of 250 ms to complete, the round-robin scheduler will suspend the
job after 100 ms and give other jobs their time on the CPU. Once the
other jobs have had their equal share (100 ms each), job1 will get another
allocation of CPU time and the cycle will repeat. This process continues
until the job finishes and needs no more time on the CPU.
• Job1 = Total time to complete 250 ms (quantum 100 ms).
1. First allocation = 100 ms.
2. Second allocation = 100 ms.
3. Third allocation = 100 ms but job1 self-terminates after 50 ms.
4. Total CPU time of job1 = 250 ms.
2 First-Come, First-Served (FCFS) Scheduling
Process Burst Time
P1 24
P2 3
P3 3
• Suppose that the processes arrive in the order: P1, P2, P3. The Gantt
Chart for the schedule is:
P P P
0 1 2 3
24 27 30
• Waiting time for P1 = 0; P2 = 24; P3 = 27
• Average waiting time: (0 + 24 + 27)/3 = 17
ã Suppose that the processes arrive in the order P2, P3, P1. The Gantt
chart for the schedule is:
P P P
0 3 6 3
• Waiting time for P1 = 6; P2 = 0; P3 = 3
• Average waiting time: (6 + 0 + 3)/3 = 3
LOVELY PROFESSIONAL UNIVERSITY 79