What if your computer's disk could work like a smart elevator, saving precious time every second?
Why SCAN (elevator algorithm) in Operating Systems? - Purpose & Use Cases
Imagine a librarian who must fetch books from shelves scattered all over a long hallway. Without a plan, the librarian runs back and forth randomly, wasting time and energy.
Manually deciding which book to pick next can cause the librarian to zigzag inefficiently, leading to delays and frustration. This random approach is slow and can cause unnecessary waiting.
The SCAN (elevator) algorithm acts like an elevator moving in one direction, picking up requests along the way, then reversing direction. This organized path reduces wasted movement and speeds up service.
Serve requests in the order they arrive, moving disk head randomly.Move disk head in one direction, serving all requests until end, then reverse direction.It enables faster and fairer access to disk data by minimizing the travel time of the disk head.
Like an elevator in a building that picks up passengers going up, then down, efficiently serving all floors without unnecessary trips.
Manual random servicing causes delays and inefficiency.
SCAN organizes requests by direction, reducing movement.
This leads to faster, more predictable disk access times.
Practice
SCAN (elevator) disk scheduling algorithm?Solution
Step 1: Understand SCAN movement
SCAN moves the disk arm in one direction, serving all requests along the way until it reaches the last track in that direction.Step 2: Direction reversal
After reaching the end, the arm reverses direction and serves requests on the way back, similar to an elevator moving up and down.Final Answer:
The disk arm moves in one direction, servicing requests until it reaches the end, then reverses direction. -> Option BQuick Check:
SCAN = moves one way then reverses [OK]
- Confusing SCAN with FCFS (first-come, first-served)
- Thinking SCAN jumps directly to closest request
- Assuming SCAN moves randomly
Solution
Step 1: Identify SCAN's servicing order
SCAN moves the disk arm in one direction, servicing all requests in that path.Step 2: Direction reversal at end
When the arm reaches the last request or the disk end, it reverses direction and services requests on the return path.Final Answer:
It services requests by moving the arm in one direction, then reverses at the end. -> Option CQuick Check:
SCAN = one direction then reverse [OK]
- Confusing SCAN with SSTF (closest request first)
- Assuming SCAN ignores direction
- Thinking SCAN services requests randomly
Solution
Step 1: Identify current arm position and direction
The arm is at track 15 and moving towards higher tracks (upwards).Step 2: Find the closest request in the moving direction
Requests above 15 are 20, 22, and 40. The closest is track 20.Final Answer:
Track 20 -> Option AQuick Check:
SCAN services requests ahead in current direction first [OK]
- Choosing requests behind current arm position
- Ignoring arm's moving direction
- Picking the closest request overall instead of in direction
Solution
Step 1: Understand arm direction and position
The arm is at track 50 moving towards 0 (downwards).Step 2: Identify requests in arm's direction
Requests below 50 are 10, 20, 30, 40; above 50 is 60.Step 3: Find next request in direction
The closest request in the moving direction is track 40, not 60.Final Answer:
The arm will service track 40 next; the error is ignoring the arm's direction. -> Option DQuick Check:
SCAN respects arm direction when choosing requests [OK]
- Ignoring arm direction and picking closest request overall
- Assuming SCAN jumps to farthest request
- Confusing SCAN with SSTF
Solution
Step 1: Identify requests above current arm position
Arm at 50 moving up; requests above 50 are 62, 64, 95, 119, 123, 180.Step 2: Service requests upwards in order
Requests are serviced in ascending order: 62, 64, 95, 119, 123, 180.Step 3: Reach end of disk and reverse
SCAN continues to the last track (199) before reversing direction.Step 4: Service remaining requests on return
On return, service requests below 50 in descending order: 34, then 11.Final Answer:
[62, 64, 95, 119, 123, 180, 199, 34, 11] -> Option AQuick Check:
SCAN = up servicing, end, then down servicing [OK]
- Skipping the last track before reversing
- Not servicing requests in sorted order
- Ignoring requests on return path
Ready to prove it?
Pass the test and this pattern moves unknown
