Algoritma Shortest Seek Time First (SSTF)
untuk penjadwlan Disk
dalam bahasa phyton, :
idenya adalah mencari posisi yang terdekat dari head. (titik awal ) ke proses proses selanjutnya.
Keuntungan dan kerugian dalam algoritma ini adalah
Advantages of Shortest Seek Time First (SSTF) –
- Better performance than FCFS scheduling algorithm.
- It provides better throughput.
- This algorithm is used in Batch Processing system where throughput is more important.
- It has less average response and waiting time.
Disadvantages of Shortest Seek Time First (SSTF) –
- Starvation is possible for some requests as it favours easy to reach request and ignores the far away processes.
- Their is lack of predictability because of high variance of response time.
- Switching direction slows things down.
Program dalam phyton
=============================================================
# Python3 program for implementation of
# SSTF disk scheduling
# Calculates difference of each
# track number with the head position
def calculateDifference(queue, head, diff):
for i in range(len(diff)):
diff[i][0] = abs(queue[i] - head)
# find unaccessed track which is
# at minimum distance from head
def findMin(diff):
index = -1
minimum = 999999999
for i in range(len(diff)):
if (not diff[i][1] and
minimum > diff[i][0]):
minimum = diff[i][0]
index = i
return index
def shortestSeekTimeFirst(request, head):
if (len(request) == 0):
return
l = len(request)
diff = [0] * l
# initialize array
for i in range(l):
diff[i] = [0, 0]
# count total number of seek operation
seek_count = 0
# stores sequence in which disk
# access is done
seek_sequence = [0] * (l + 1)
for i in range(l):
seek_sequence[i] = head
calculateDifference(request, head, diff)
index = findMin(diff)
diff[index][1] = True
# increase the total count
seek_count += diff[index][0]
# accessed track is now new head
head = request[index]
# for last accessed track
seek_sequence[len(seek_sequence) - 1] = head
print("Total number of seek operations =",
seek_count)
print("Seek Sequence is/ /Urutan Proses nya : ")
# print the sequence
for i in range(l + 1):
print(seek_sequence[i])
# Driver code
if __name__ =="__main__":
# request array
proc = [176, 79, 34, 60,
92, 11, 41, 114]
print("Data awal adalah ", proc)
print("Titik Awal di posisi 50 ")
print(" ")
shortestSeekTimeFirst(proc, 50)
# This code is contributed by
# Shubham Singh(SHUBHAMSINGH10)
# Modified by andrew @2020
============================================================
video youtube menyusul
No comments:
Post a Comment