Skip to content

Commit 3390e44

Browse files
authored
FCFS
1 parent 692554f commit 3390e44

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Disk Scheduling/mainn.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//FCFS
2+
3+
#include<stdio.h>
4+
#include<stdlib.h>
5+
int main()
6+
{
7+
int RQ[100],i,n,TotalHeadMoment=0,initial;
8+
printf("Enter the number of Requests\n");
9+
scanf("%d",&n);
10+
printf("Enter the Requests sequence\n");
11+
for(i=0;i<n;i++)
12+
scanf("%d",&RQ[i]);
13+
printf("Enter initial head position\n");
14+
scanf("%d",&initial);
15+
16+
// logic for FCFS disk scheduling
17+
18+
for(i=0;i<n;i++)
19+
{
20+
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
21+
initial=RQ[i];
22+
}
23+
24+
printf("Total head moment is %d",TotalHeadMoment);
25+
return 0;
26+
}

0 commit comments

Comments
 (0)