In: Computer Science
An operating system uses the First-Come, First-Served (FCFS) CPU scheduling algorithm.
Consider the following set of processes in this OS, with the length of the CPU burst time given in milliseconds, and the shown priority. A larger priority number implies a higher priority. There is no pre-emption.
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.
Process | Burst Time | Priority |
P1 | 2 | 2 |
P2 | 1 | 5 |
P3 | 4 | 1 |
P4 | 6 | 4 |
P5 | 3 | 3 |
a) Draw a Gantt chart illustrating the order of execution of these processes, showing their completion times.
b) Calculate each process’ waiting time, and then compute the average waiting time for this set.
Note: waiting time = completion time – arrival time – burst time
=> Write your answers on scratch paper (make sure it is visible) then take a picture of it and upload it here.
As given that the larger priority number implies higher priority means 5 is the highest priority while 1 is the lowest priority.
Process |
Burst Time |
Priority |
P1 |
2 |
2 |
P2 |
1 |
5 |
P3 |
4 |
1 |
P4 |
6 |
4 |
P5 |
3 |
3 |
a)
All process are arriving at time 0.
So process based on the higher priority is executed first. Process P2 has a higher priority which is 5. so first process P2 is executed and completed at time 1. Then process p4 has higher priority which is 4. so second process P4 is executed . Then process P5 has higher priority which is 3. so third process P5 is executed. Then process P1 has higher priority which is 2. so then process P1 is exceuted . Then process P3 is executed.
Gantt Chart:
P2 |
P4 |
P5 |
P1 |
P3 |
0 1 7 10 12 16
b)
Waiting time of each process:
P1 = 12 - 0 - 2 =10
P2 = 1 - 0 - 1 = 0
P3 = 16 - 0 - 4 = 12
P4 = 7 - 0 - 6 = 1
P5 = 10 - 0 - 3 = 7
Average waiting time = ( 10 + 0 + 12 + 1 + 7) / 5
= 30 / 5
=6
So average waiting time is 6.