-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcfs_disk.c
More file actions
32 lines (24 loc) · 754 Bytes
/
Copy pathfcfs_disk.c
File metadata and controls
32 lines (24 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
int main() {
int i, seekTime = 0, totalRequests, requests[100], start;
printf("Enter the head position : ");
scanf("%d", &start);
printf("Enter the total requests : ");
scanf("%d", &totalRequests);
printf("Enter the request sequence\n");
for(int i = 0; i < totalRequests; i++) {
scanf("%d", &requests[i]);
}
printf("Head movements : %d -> ", start);
for(int i = 0; i < totalRequests; i++) {
if(start < requests[i]) {
seekTime += requests[i] - start;
} else {
seekTime += start - requests[i];
}
printf("%d -> ", requests[i]);
start = requests[i];
}
printf("\nTotal seek time = %d", seekTime);
return 0;
}