First come first serve (FCFS) scheduling algorithm simply execute the jobs/process according to their arrival time. The process which comes first in the ready queue will get the CPU first.
Example: 1
Criteria: Non-Preemptive
Mode: Process Arriving in the order and first process have more Burst Time
Let’s take an example of The FCFS scheduling algorithm. In the Following schedule, there are 3 processes with process P1, P2 and P3. P1 arrives at time 0, P2 at time 1 and P3 arrives at time 2 in the ready queue. The processes and their respective Arrival and Burst time are given in the following table.
Process | Burst Time |
---|---|
P1 | 24 |
P2 | 3 |
P3 | 3 |
Solution
Lets draw the Gantt Chart. Suppose the process arrive in the order P1,P2,P3
(Gantt chart)
Start Time/Wait Time for first process is 0 always if arrival time not given.
Waiting Time for P1 => 0
Waiting Time for P2 => 24
Waiting Time for P3 => 27
Process | Burst Time | Waiting Time |
---|---|---|
P1 | 24 | 0 |
P2 | 3 | 24 |
P3 | 3 | 27 |
Average Waiting Time(AWT) =(0+24+27)/3
= 51/3
= 17
Example: 2
Criteria: Non-Preemptive
Mode: Process Arriving in Different order and first process have low Burst Time
Suppose the process arrive in the order P3,P2, P1
Process | Burst Time |
---|---|
P3 | 3 |
P2 | 3 |
P1 | 24 |
Solution
(Gantt chart)
Waiting Time for P1 => 6
Waiting Time for P2 => 3
Waiting Time for P3 => 0
Process | Burst Time | Waiting Time |
---|---|---|
P3 | 3 | 0 |
P2 | 3 | 3 |
P1 | 24 | 6 |
Average Waiting Time(AWT) =(6+3+0)/3
= 9/3
= 3
Advantages of FCFS
- Simplest form of CPU Scheduling Algorithm
- Easy to Program
- First come, First served like FIFO Queue Model
Disadvantages of FCFS
- Poor Performance
- Average waiting time is higher as compare to other scheduling algorithms.
- It is a Non-Preemptive CPU scheduling algorithm, so after the process has been allocated to the CPU, it will never release the CPU until it finishes executing.
- Average Waiting Time is not optimal
- Cannot utilize resources in parallel. Convoy Effect may occur
Convoy Effect in FCFS
Convoy Effect can occur in FCFS like suppose the first process which arrived in the queue has a huge burst time…so for that time all other processes will have to wait…this is convoy effect like a minister is crossing the road and all other traffic has to wait for some time….but it will not be infinite…all processes will eventually get a chance..
Convoy effect in Operating System is a phenomenon (in First come First serve) in which whole operating system slows down due to few slow process. As FCFS is a non-preemptive scheduling algorithm, the CPU will be allocated to a process until it get finished, that means other processes have to wait for their turn.
Starvation is the phenomena in which a process is not able to acquire the desired resources (like processor, I/O device etc) for a very long time to progress with its execution.
A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs ceasing to function.
#average waiting time #convoy effect #cpu scheduling algorithm #fcfs #operating system #os #scheduling algorithm #waiting time