C-Program of FCFS (First come first serve) Disk scheduling Algorithms in operating system (OS).

  What is FCFS (first come first serve)disk scheduling:-

                                                                                                   FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are addressed in the order they arrive in the disk queue. Example: Given the following queue — 95, 180, 34, 119, 11, 123, 62, 64 with the Read-write head initially at the track 50 and the tail track being at 199.

Advantage:-

  1. easy to understand and implement
  2. No starvation occur

Disadvantage:-

  1. Throughput is not very efficient
  2. Waiting and response time is more

Code:-

#include<stdio.h>
#include<stdlib.h>
int main()
{
int RQ[100],i,n,TotalHeadMoment=0,initial;
printf(“Enter the number of Requestsn”);
scanf(“%d”,&n);
printf(“Enter the Requests sequencen”);
for(i=0;i<n;i++)
scanf(“%d”,&RQ[i]);
printf(“Enter initial head positionn”);
scanf(“%d”,&initial);
// logic for FCFS disk scheduling
for(i=0;i<n;i++)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
printf(“Total head moment is %d”,TotalHeadMoment);
return 0;
}

Output:-

Enter the number of Request
8
Enter the Requests Sequence
95 180 34 119 11 123 62 64
Enter initial head position
50
Total head movement is 644

 Program of disk scheduling algorithm

Recommended Post:

Hackerearth Problems:-

Data structure:-

Key points:-

 MCQs:-

Leave a Reply

Your email address will not be published.