Tuesday 4 October 2011

FIRST IN FIRST OUT (FIFO) :

First In First Out (FIFO)

This is a Non-Premptive scheduling algorithm. FIFO strategy assigns priority to processes in the order in which they request the processor.The process that requests the CPU first is allocated the CPU first.When a process comes in, add its PCB to the tail of ready queue. When running process terminates, dequeue the process (PCB) at head of ready queue and run it.
Consider the example with P1=24, P2=3, P3=3
 
  Gantt Chart for FCFS :  0 - 24 P1 , 25 - 27 P2 , 28 - 30 P3
 
  Turnaround time for P1 = 24
  Turnaround time for P1 = 24 + 3
  Turnaround time for P1 = 24 + 3 + 3
 
  Average Turnaround time = (24*3 + 3*2 + 3*1) / 3
 
  In general we have (n*a + (n-1)*b + ....) / n
 
  If we want to minimize this, a should be the smallest, followed by b and
  so on.
Comments: While the FIFO algorithm is easy to implement, it ignores the service time request and all other criteria that may influence the performance with respect to turnaround or waiting time.
Problem: One Process can monopolize CPU
Solution: Limit the amount of time a process can run without a context switch. This time is called a time slice.

0 comments:

Post a Comment