FCFS (First-Come-First Serve) is a disk scheduling algorithm used by the memory-management unit.
We know that a disk contains
In the FCFS algorithm, there is no starvation since requests are processed immediately.
There is a problem with performance because the RW-header doesn’t check the future requests.
Lets consider a disk contain 200 tracks(0-199)
and a request queue contains track number [82,170,43,140,24,16,190 ]
, respectively. The current position of read-write head=50
.
Find the total number of track movements in cylinders.
7
82 170 43 140 24 16 190
50
#include<stdio.h>#include<stdlib.h>int main(){int ReadyQueue[100],i,n,TotalHeadMov=0,initial;//Enter the number of requestsscanf("%d",&n);for(i=0;i<n;i++){//Enter the sequence of requestscanf("%d",&ReadyQueue[i]);}// Enter initial head positionscanf("%d",&initial);for(i=0;i<n;i++){TotalHeadMov=TotalHeadMov+abs(ReadyQueue[i]-initial);initial=ReadyQueue[i];}printf("Total Head Movement=%d",TotalHeadMov);}
Enter the input below
ReadyQueue[100]
, Total head movementTotalHeadMov
and initial
for header position n
for the size of ready queue, i
is a looping variable.number of requests
,sequence of requests
and initial head position
.