You are on page 1of 5

Do problems 6.3(Tiffany), 6.4 (Lanhui) and 6.9 (Tao). 6.

3 a) Draw four Gantt charts that


illustrate the execution of these processes using FCFS,SJF, a nonpreemptive priority, and RR
scheduling
FCFS
p1 p2 p3 p4 p5
---------- | - | -- | - | -----
10 11 13 14 19

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.

Process Arrival Time Burst Time


P1 0.0 8
P2 0.4 4
P3 1.0 1
a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?

FCFS Gantt Chart


Proc: 1 2 3
|---------------|-------|--|
Time: 0 8 12 13

Average Turnaround Time: ( (8-0)+(12-0.4)+(13-1.0) ) / 3 = 10.53

b. What is the average turnaround time for these processes with the SJF scheduling algorithm?

SJF Gantt Chart


Proc: 1 3 2
|---------------|--|--------|
Time: 0 8 9 13

Average Turnaround Time: ( (8-0)+(13-0.4)+(9-1.0) ) / 3 = 9.53

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:

Waiting time for P1=0

Waiting time for P2=10


Waiting time for P3=11

Waiting time for P4=13

Waiting time for P5=14

Average waiting time=SumofwaitingtimeforindividualprocessNo.ofprocesses

=0+10+11+13+145=9.6

Average execution time=SumofexecutiontimeforindividualprocessNo.ofprocesses

=10+1+2+1+55=3.8

Average turn-around time = Average waiting time + Average execution time = 9.6 + 3.8 =
13.4

b) SJF non-preemptive scheduling:

Here the processes are scheduled as per their burst time with the least timed-process being given
the maximum priority.

Waiting time for P1=9

Waiting time for P2=0

Waiting time for P3=2

Waiting time for P4=1

Waiting time for P5=4

Average waiting time=SumofwaitingtimeforindividualprocessNo.ofprocesses

=9+0+2+1+45=3.2

Average execution time=SumofexecutiontimeforindividualprocessNo.ofprocesses

=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)

Waiting time for P1=6

Waiting time for P2=0

Waiting time for P3=16

Waiting time for P4=18

Waiting time for P5=1

Average waiting time=SumofwaitingtimeforindividualprocessNo.ofprocesses

=6+0+16+18+15=8.2

Average execution time=SumofexecutiontimeforindividualprocessNo.ofprocesses

=10+1+2+1+55=3.8

Average turn-around time= Average waiting time + Average execution time = 8.2 + 3.8 = 12

d) Round Robin scheduling:

Here every process executes in the FCFS for the given time quantum. This is a pre-emptive
method of scheduling. Here time quantum =1

Waiting time for P1=(0+(5−1)+(8−6)+(10−9)+(12−11)+(14−13))=9

Waiting time for P2=1

Waiting time for P3=2+(6−3)=5


Waiting time for P4=3

Waiting time for P5=4+(7−5)+(9−8)+(11−10)+(13−12)=9

Average waiting time=SumofwaitingtimeforindividualprocessNo.ofprocesses

=9+1+5+3+95=5.4

Average execution time=SumofexecutiontimeforindividualprocessNo.ofprocesses

=10+1+2+1+55=3.8

Average turn-around time= Average waiting time + Average execution time = 5.4 + 3.8 = 9.2

You might also like