Professional Documents
Culture Documents
Output:
Output:
Head moves from 53 to 98 = 45
Head moves from 98 to 183 = 85
Head moves from 183 to 37 = 146
Head moves from 37 to 122 = 85
Head moves from 122 to 14 = 108
Head moves from 14 to 124 = 110
Head moves from 124 to 65 = 59
Head moves from 65 to 67 = 2
Total number of head movements = 640
(2) Shortest Seek Time First - Disk Scheduling Algorithm
Program:
#include<stdio.h>
main()
{
int q[10]={98,183,37,122,14,124,65,67},n=8;
int start=53,seek=0,i,j,d,index,min,done[10];
for(i=0;i<n;i++)
done[i]=0;
for(i=0;i<n;i++)
{
min=9999;
for(j=0;j<n;j++)
if(abs(start-q[j])<min && !done[j] )
{
min=abs(start-q[j]);
index=j;
}
done[index]=1;
d=abs(start-q[index]);
printf("\nHead moves from %4d to %4d = %4d",start,q[index],d);
start=q[index];
seek+=d;
}
printf("\nTotal number of head movements =%4d",seek);
}
Output: