Operating System: Cset209
Operating System: Cset209
SYSTEM: CSET209
S
CONTENTS COVERED
The average TAT and WT are determined by summing the respective TAT and WT of all
the processes and divided the sum by the total number of processes (n).
METRICS TO MEASURE PERFORMANCE OF A CPU SCHEDULING ALGO
First come first serve (FCFS) scheduling algorithm simply schedules the jobs according
to their arrival time. The job which comes first in the ready queue will get the CPU first.
The lesser the arrival time of the job, the sooner will the job get the CPU.
Advantages of FCFS
• Simple and Easy to implement.
Disadvantages of FCFS
Non-preemptive
Average Waiting Time is not optimal
Cannot utilize resources in parallel (Results in Convoy effect )
(FCFS) SCHEDULING: EXAMPLE 1
The average TAT and WT are determined by summing the respective TAT and WT of all
the processes and divided the sum by the total number of processes.
(FCFS) SCHEDULING: EXAMPLE 1
Here we have 5 processes with process ID P0, P1, P2, P3 and P4. P0 arrives at time 0,
P1 at time 1, P2 at time 2, P3 arrives at time 3 and Process P4 arrives at time 4 in the
ready queue. The processes and their respective Arrival and Burst time are given in
the following table.
Process ID Arrival Time Burst Time Completion Time Turn Around Waiting Time
(millisecond) Time (TAT) (WT)
P0 0 2
P1 1 6
P2 2 4
P3 3 9
P4 6 12
FCFS SCHEDULING
(FCFS) SCHEDULING: EXAMPLE 1
Process ID Arrival Time Burst Time Completion Time Turn Around Waiting Time
(millisecond) Time (TAT) (WT)
P0 0 2 2 2 0
P1 1 6 8 7 1
P2 2 4 12 10 6
P3 3 9 21 18 9
P4 6 12 33 29 17
Example: 2
Calculate following:
1. Calculate waiting time for all process
2. Average waiting time
3. Calculate turnaround time for all process
4. Average turnaround time
(FCFS) SCHEDULING: EXAMPLE 2
P1 P3 P2 P4
P1 P3 P2 P4
0 1 2 3 4 8 9
2 1 3 43 42 39
3 1 1 44 43 42
ILLUSTRATING CONVOY EFFECT IN FCFS
Case 2: In the Second scenario, If Process P1 would have arrived at the last of the
queue and the other processes P2 and P3 at earlier then the problem of starvation
would not be there. Following example shows the deviation in the waiting times of
both the scenarios. Although the length of the schedule is same that is 44 units but
the waiting time will be lesser in this schedule.
P1 P3 P2 P4
0 3 7 8 12 16
P4 P1 P3 P2
0 3 9 16 24
1 0 9 13 13 4
2 1 4 5 4 0
Avt TAT = 37/3=12.33 msec
Avg Waiting Time = (4+0+11)/3 = 5 msec. 3 2 9 22 20 11
PREEMPTIVE SRTF EXAMPLE 2
Now we add the concepts of varying arrival times and preemption to the
analysis
ProcessA arri Arrival TimeT Burst Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5
Preemptive SJF Gantt Chart
P1 P2 P4 P1 P3
0 1 5 10 17 26