FCFS Disk Scheduling Algorithm
Given an array of disk track numbers and initial head position, our task is to find the total number of seek operations done to access all the requested tracks if First Come First Serve (FCFS) disk scheduling algorithm is used.
First Come First Serve (FCFS)
FCFS is the simplest As the name suggests, this algorithm entertains requests in the order they arrive in the disk queue. The algorithm looks very fair and there is no starvation (all requests are serviced sequentially) but generally, it does not provide the fastest service.
FCFS is the simplest As the name suggests, this algorithm entertains requests in the order they arrive in the disk queue. The algorithm looks very fair and there is no starvation (all requests are serviced sequentially) but generally, it does not provide the fastest service.
tracks,q,st,total=[],[],0 ,0
n=int(input("Enter no of tracks"))
n=n+1
start=int(input("Enter the start track"))
tracks.append(start)
print("enter req tracks")
for i in range(1,n):
tracks.append(int(input()))
print("Seek Time Calculation")
for i in range(0,int(n)-1):
if(tracks[i]>tracks[i+1]):
st=tracks[i]-tracks[i+1]
total=total+st
print(str(tracks[i])+"-"+str(tracks[i+1])+"="+str(st))
else:
st=tracks[i+1]-tracks[i]
total=total+st
print(str(tracks[i+1])+"-"+str(tracks[i])+"="+str(st))
n=n-1
print("Total seek time :: "+str(total),"\n"+"avg seek time :: "+str(total/n))
Post a Comment