Presentation is loading. Please wait.

Presentation is loading. Please wait.

Process CPUArrival Time P1 24 7 P2 3 0 P3 3 0 The Gantt Chart for the schedule is: 0 3 6 7 31 Waiting time for P1 = (7-7)=0; P2 = (0-0)=0; P3 = (3-0)

Similar presentations


Presentation on theme: "Process CPUArrival Time P1 24 7 P2 3 0 P3 3 0 The Gantt Chart for the schedule is: 0 3 6 7 31 Waiting time for P1 = (7-7)=0; P2 = (0-0)=0; P3 = (3-0)"— Presentation transcript:

1

2 Process CPUArrival Time P1 24 7 P2 3 0 P3 3 0 The Gantt Chart for the schedule is: 0 3 6 7 31 Waiting time for P1 = (7-7)=0; P2 = (0-0)=0; P3 = (3-0) =3 Average waiting time: (0 + 0 + 3)/3 = 1 average waiting time P2P3P1idle

3

4 Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. Two schemes: 1. non pre- emptive – once CPU given to the process it cannot be preempted until completes its CPU burst. 2. preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF). SJF is optimal – gives minimum average waiting time for a given set of processes. Process Arrival Time CPU P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (non-preemptive) 0 7 8 12 16 Waiting time: P1–(0-0)=0, P2 – (8-2)=6, P3–(7-4)=3, P4–(12-5)=7 A.W.T= 0+6+3+7= 16/4 = 4 average waiting time. P1P3P2P4

5 Process Arrival Time CPU P1 0.0 7,5,0 P2 2.0 4,2,0 P3 4.0 1,0 P4 5.0 4,0 SRTF (Pre-emptive) 0 2 4 5 7 1116 +7 +4 +1 +2+4 7 6 5 711 -2 -4 5 2 Waiting time: P1–(0-0) + (11-2)=9, P2 – (2-2) + (5-4)=1, P3–(4-4)=0, P4–(7-5)=2 A.W.T.= 9+1+0+2= 12/4 = 3 average waiting time. P1P2P3P2P4P1

6 A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority). 1. Preemptive 2. Non-preemptive SJF is a priority scheduling where priority is the predicted next CPU burst time. Process CPUPRI P1 72 P2 41 P3 13 P4 41 01 8 1216 0+1+8+12+16=37/3= 12 1/3 average waiting time P3P1P2P4

7 If Q>CPU then, CPU minus the quantum otherwise, CPU burst time in. Example :Time Quantum = 4 Process CPU Arrival Time P1 24,20,16,12,8,4,01 P2 3,00 P3 3,02 The Gantt chart is: 0 3 7 10 14 18 22 26 30 +4 +3 +4 +4 +4 +4 +4 Average waiting time = P1=(3-1)+(10-7)=2+3=5; P2=(0-0)=0; P3=(7-2)=5 5+0+5=10/3= 3 1/3 average waiting time P2P1P3P1P1P1P1P1


Download ppt "Process CPUArrival Time P1 24 7 P2 3 0 P3 3 0 The Gantt Chart for the schedule is: 0 3 6 7 31 Waiting time for P1 = (7-7)=0; P2 = (0-0)=0; P3 = (3-0)"

Similar presentations


Ads by Google