You are on page 1of 6

1.

Consider five processes, P1, P2, P3, P4 and P5, with CPU burst times of 10, 29, 3, 7, and 12 milliseconds, respectively. Arrival order P1, P2, P3, P4, P5 at time 0 ms. a) Draw Gantt charts for the FCFS, SJF and RR scheduling algorithms (time quantum of 10 ms) b) Which of these algorithms would give the minimum average waiting time? c) Compare the average turnaround time between SJF and RR scheduling algorithms Process Burst time P1 10 P2 29 P3 3 P4 7 P5 12 Ans: i) a. FCFS P1 0 P2 10 P3 39 P4 42 P5 49 61 Gantt Chart

AWT=(0+10+39+42+49)/5=28ms b. SJF P3 0 P4 3 P1 10 P5 20 P2 32 61

AWT=(10+32+0+3+20)/5=13ms c.RR P1 P2 0 10 P3 20 P4 P5 23 P2 P5 P2 30

40

50

52

61

AWT=(0+32+20+23+40)/5=23ms ii)MIN Average waiting time= SJF=13ms iii)Turnaround time SJF P1=20 P2=61 P3=3

P4=10 P5=32 ATT=(20+61+3+10+32)/5=25.2ms RR P1=10 P2=61 P3=23 P4=30 P5=52 ATT=(10+61+23+30+52)/5=35.2ms Average Turnaround time of SJF is 25.2ms and it is lesser than RR average turnaround time which is 35.2ms.

2. Consider the following set of Processes, with the length of the CPU-burst time given in milliseconds: Process P1 P2 P3 P4 P5 Burst time 8 1 3 1 6 Priority 4 2 4 5 3

The processes are assumed to have arrived in the order p1, p2, p3, p4, p5 all at time 0 ms. i). Draw 4 Gantt charts illustrating the execution of these processes using FCFS, SJF, a nonpreemptive priority and RR (quantum = 1 ms) Scheduling. ii). what is the waiting time of each process for each of the scheduling algorithm in part i). iii). which of the Schedules in part (i) results in the minimal average time.

Ans: i)Gantt chart FCFS P1 0 SJF P2 0 P4 P3 1 2 P5 5 P1 11 19 P2 8 P3 9 P4 P5 12 13 19

Non pre-emptive priority P2 P5 0 1 RR P1 P2 P3 P4 P5 P1 P3 P5 P1 P3 P5 P1 P5 P1 P5 P1 P5 P1 P1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 11 17 18 19 ii)Waiting time for each process FCFS P1=0 P2=8 P3=9 P4=12 P5=13 SJF P1=11 P2=0 P3=2 P4=1 P5=5 AWT=3.8ms AWT=8.4ms P1 7 P3 15 P4 18 19

NON PRE-EMPTIVE PRIORITY P1=7 P2=0 P3=15 P4=18 P5=1 AWT=8.2ms

Waiting time for each process in RR P1=0+4+2+2+1+1+1=11 P2=1 P3=2+3+2=7 P4=3 P5=4+2+2+1+1+1=11 AWT=6.6ms iii)SJF results in minimal average waiting time which is 3.8ms. 3. Consider the following set of Processes, with the length of the CPU-burst time given in milliseconds: Process Burst time Priority: Process Burst time Priority P1 7 2 P2 5 3 P3 3 1 The processes are assumed to have arrived in the order p1,p2,p3 all at time 0 ms. i) Draw the Gantt charts illustrating the execution of these processes using FCFS, SJF (nonpreemptive) and priority. ii). What is the average turnaround time for these processes with each of the algorithms mentioned in part(i). iii). What is the average waiting time for these processes with each of the algorithms mentioned in part(i).

Ans: i)Gantt chart FCFS P1 0 SJF P3 0 Priority P3 0 P1 3 P2 10 15 P2 3 8 P1 15 P2 7 P3 12 15

ii)Average turnaround time ATT FCFS=(7+12+15)/3=11.3ms ATT SJF=(15+8+3)/3=8.6ms ATT PRIORITY=(10+15+3)/3=9.3ms iii)Average waiting time AWT FCFS=(0+7+12)/3=6.3ms AWT SJF=(8+3+0)/3=3.6ms AWT PRIORITY=(3+10+0)/3=4.3ms

4. Given the following Information :

Process Arr.time Bursttime P1 P2 P3 P4 0 1 2 3 8 4 9 5

i) Draw the Gantt chart illustrating the execution of processes using FCFS, RR and SJF (preemptive)

ii) Calculate the average waiting time and turnaround time for each process using a)FCFS b) RR (quantum = 3ms) c) SJF (Preemptive) Ans: i) Gantt Chart FCFS P1 0 RR P1 0 SJF P1 0 P2 1 P4 5 P1 10 P3 17 26 P2 3 P3 6 P4 9 P1 12 P2 15 P3 16 P4 19 P1 21 P3 23 26 P2 8 P3 12 P4 21 26

ii)Average Waiting time: FCFS=(0+8+12+21)/4=10.2ms RR=(15+12+17+16)/4=15ms SJF=(9+1+17+5)/4=8ms Average Turnaround time: FCFS=(8+12+21+26)/4=16.7ms RR=(23+16+26+21)/4=21.5ms SJF=(17+5+26+10)/4=14.5ms

You might also like