What is SSTF disk scheduling:-
Shortest seek time first (SSTF) algorithm selects the disk I/O request which requires the least disk arm movement from its current position regardless of the direction. It reduces the total seek time as compared to FCFS.
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:-
- seek time reduces as compared to the FCFS
- Less waiting time and response time
- Increase throughput.
Disadvantage:-
- starvation occurred
import sys
n = int(input("Enter the number of Requests\n"))
RQ =list(map(int,input().split()))
print("Enter the Requests sequence")
initial = int(input("Enter initial head position\n"))
# logic for sstf disk scheduling
count = 0
TotalHeadMoment = 0
# loop will execute until all processes are completed
while count != n:
mini = sys.maxsize
d = index = 0
for i in range(n):
d = abs(RQ[i] - initial)
if mini > d:
mini = d
index = i
TotalHeadMoment += mini
initial = RQ[index]
RQ[index] = sys.maxsize
count += 1
print("Total head movement is", TotalHeadMoment)
Output:-
Enter the number of Request
8
Enter Request Sequence
95 180 34 119 11 123 62 64
Enter initial head Position
50
Total head movement is 236
Must Visit:-
See more:-
- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation
0 Comments