0
0
Operating Systemsknowledge~10 mins

SSTF (Shortest Seek Time First) in Operating Systems - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate the next disk request chosen by SSTF.

Operating Systems
next_request = min(requests, key=lambda r: abs(r - [1]))
Drag options to blanks, or click blank then click option'
Acurrent_head_position
Brequest
Crequests
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using the request variable inside the abs() instead of the current head position.
Confusing the list of requests with the current position.
2fill in blank
medium

Complete the code to remove the served request from the list after SSTF selects it.

Operating Systems
requests.remove([1])
Drag options to blanks, or click blank then click option'
Amin
Bcurrent_head_position
Crequests
Dnext_request
Attempts:
3 left
💡 Hint
Common Mistakes
Removing the current head position instead of the request.
Trying to remove the entire list of requests.
3fill in blank
hard

Fix the error in updating the current head position after serving a request.

Operating Systems
current_head_position = [1]
Drag options to blanks, or click blank then click option'
Anext_request
Bmax(requests)
Cmin(requests)
Drequests[0]
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the head to the first or last request in the list instead of the served request.
Not updating the head position at all.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each request to its distance from the current head position.

Operating Systems
distances = {r: abs(r [1] current_head_position) for r in requests if r [2] current_head_position}
Drag options to blanks, or click blank then click option'
A-
B>
C<
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction for distance.
Filtering requests less than the current head position.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each request to its distance from the current head position, considering requests both less and greater than the head.

Operating Systems
distances = {r: abs(r [1] current_head_position) for r in requests if r [2] current_head_position or r [3] current_head_position}
Drag options to blanks, or click blank then click option'
A-
B>
C<
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction.
Filtering only requests greater than the head.