Professional Documents
Culture Documents
p2 p4 p3 p5 p1
SJF - | - | -- | -----| ----------
1 2 4 9 19
nonpreemptive priority
p2 p5 p1 p3 p4
- | ----- | ---------- | -- | -
1 6 16 18 19
p1 p2 p3 p4 p5 p1 p3 p5 p1 p5 p1 p5 p1 p5 p1 p1 p1 p1 p1
RR - | - | - | - | - | - | - | - | - | - | - | - | - | - | -|- |-| - | -|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
b) what is the turnaround time of each process for each of the scheduling algorithms in part a
FCFS p1 :10 p2:11 P3:13 p4:14 p5:19
SJF p1 :19 p2:1 p3: 4 p4: 2 p5: 9
NonP p1 :16 p2:1 p3:18 p4:19 p5: 6
RR p1 :19 p2:2 p3: 7 p4: 4 p5:14
c) what is the waiting time of each process for each of the scheduling algorithms in part a?
FCFS p1 : 0 p2:10 p3:11 p4:13 p5:14
SJF p1 : 9 p2: 0 p3: 2 p4: 1 p5: 4
NonP p1 : 6 p2: 0 p3:16 p4:18 p5: 1
RR p1 : 9 p2: 1 p3: 5 p4: 3 p5: 9
d) which of the schedules in part a results in the minimal average waiting time (over all
processes)
FCFS avg: (0+10+11+13+14)/5 = 9.6
SJF avg: (9+0+2+1+4)/5 = 3.2
NonP avg: (6+0+16+18+1)/5 = 8.2
NonP avg: (6+0+16+18+1)/5 = 8.2
RR avg: (9+1+5+3+9)/5 = 5.4
SJF results in the minimal average waiting time.
Ch6.4 Suppose that the following processes arrive for execution at the times indicated. Each
process will run the listed amount of time. In answering the questions, use nonpreemptive
scheduling and base all decisions on the information you have at the time the decision must be
made.
b. What is the average turnaround time for these processes with the SJF scheduling algorithm?
Question: Consider the following set of processes, with the length of CPU burst given in
milliseconds.
The processes are assumed to have arrived in the order P1,P2,P3,P4,P5 all at time 0. Draw gnat
charts for the following scheduling algorithms FCFS, SJF non preemptive, priority and
RR(quantum=1) and also calculate turn-around time, average waiting time.
a) FCFS scheduling:
Here the processes are scheduled as per the order in which they arrive.
Gantt chart:
=0+10+11+13+145=9.6
=10+1+2+1+55=3.8
Average turn-around time = Average waiting time + Average execution time = 9.6 + 3.8 =
13.4
Here the processes are scheduled as per their burst time with the least timed-process being given
the maximum priority.
=9+0+2+1+45=3.2
=10+1+2+1+55=3.8
Average turn-around time= Average waiting time + Average execution time = 3.2 + 3.8 = 7
c) Priority scheduling :
Here the scheduling happens on the basis of priority number assigned to each process. (Here we
would be considering Priority=1 as highest priority)
=6+0+16+18+15=8.2
=10+1+2+1+55=3.8
Average turn-around time= Average waiting time + Average execution time = 8.2 + 3.8 = 12
Here every process executes in the FCFS for the given time quantum. This is a pre-emptive
method of scheduling. Here time quantum =1
=9+1+5+3+95=5.4
=10+1+2+1+55=3.8
Average turn-around time= Average waiting time + Average execution time = 5.4 + 3.8 = 9.2