0
0
Operating Systemsknowledge~30 mins

FCFS disk scheduling in Operating Systems - Mini Project: Build & Apply

Choose your learning style9 modes available
FCFS Disk Scheduling Simulation
📖 Scenario: You are managing a computer's disk drive. The disk head moves to read data from different tracks on the disk. The requests come in a certain order, and you want to simulate how the disk head moves using the First-Come, First-Served (FCFS) scheduling method.
🎯 Goal: Build a simple step-by-step simulation of the FCFS disk scheduling algorithm. You will create the list of disk requests, set the initial head position, calculate the total head movement as the disk head moves to each requested track in order, and finally complete the simulation by showing the total movement.
📋 What You'll Learn
Create a list called requests with the exact disk track numbers: 98, 183, 37, 122, 14, 124, 65, 67
Create a variable called head with the initial disk head position set to 53
Use a variable called total_movement to keep track of the total distance the disk head moves
Use a for loop with variables request to iterate over requests in order
Calculate the absolute distance between the current head position and the request, add it to total_movement, then update head to the request
At the end, have a variable called result that stores the total head movement as an integer
💡 Why This Matters
🌍 Real World
Disk scheduling algorithms help operating systems decide the order to access data on a hard drive, improving speed and efficiency.
💼 Career
Understanding disk scheduling is important for roles in system administration, operating system development, and performance optimization.
Progress0 / 4 steps
1
Create the list of disk requests
Create a list called requests with these exact disk track numbers in order: 98, 183, 37, 122, 14, 124, 65, 67
Operating Systems
Need a hint?

Use square brackets [] to create a list and separate the numbers with commas.

2
Set the initial disk head position
Create a variable called head and set it to the initial disk head position 53
Operating Systems
Need a hint?

Use a simple assignment to create the variable head with the value 53.

3
Calculate total head movement using FCFS
Create a variable called total_movement and set it to 0. Then use a for loop with variable request to iterate over requests. Inside the loop, calculate the absolute distance between head and request, add it to total_movement, and update head to request
Operating Systems
Need a hint?

Use abs() to get the absolute difference between two numbers.

4
Store the final total head movement
Create a variable called result and set it equal to total_movement to store the total distance the disk head moved
Operating Systems
Need a hint?

Simply assign result to the value of total_movement.