0
0
Operating Systemsknowledge~10 mins

FCFS disk scheduling 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 total head movement in FCFS disk scheduling.

Operating Systems
total_movement = 0
for i in range(1, len(requests)):
    total_movement += abs(requests[i] [1] requests[i-1])
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 inside the absolute value.
Forgetting to use absolute value, which can cause negative distances.
2fill in blank
medium

Complete the code to initialize the starting position of the disk head.

Operating Systems
head_position = [1]
Drag options to blanks, or click blank then click option'
Arequests[0]
B-1
C0
Dlen(requests)
Attempts:
3 left
💡 Hint
Common Mistakes
Setting head position to 0 regardless of requests.
Using the length of requests instead of a position.
3fill in blank
hard

Fix the error in the loop that calculates head movement for FCFS scheduling.

Operating Systems
for i in range(1, len(requests)):
    movement = abs(requests[i] [1] requests[i-1])
    total_movement += movement
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same index for both current and previous requests.
Using addition instead of subtraction.
4fill in blank
hard

Fill both blanks to create a dictionary that maps each request to its head movement from the previous request.

Operating Systems
movements = {req: abs(req [1] prev) for req, prev in zip(requests[1:], requests[2])}
Drag options to blanks, or click blank then click option'
A-
B+
C[:-1]
D[1:]
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction.
Using the wrong slice for previous requests.
5fill in blank
hard

Fill all three blanks to compute total head movement and print the result in FCFS disk scheduling.

Operating Systems
total_movement = 0
for i in range(1, [1]):
    total_movement += abs(requests[i] [2] requests[i-1])
print(f"Total head movement: [3]")
Drag options to blanks, or click blank then click option'
Alen(requests)
B-
Ctotal_movement
Drequests
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong range limit in the loop.
Printing the wrong variable.