Disk Scheduling Algorithms and SSD Management Explained

1. Disk Scheduling Algorithms

In traditional Hard Disk Drives (HDDs), data is read and written by a mechanical disk head moving across spinning platters. Because mechanical movement is slow, the operating system uses Disk Scheduling Algorithms to order incoming I/O requests. The main goal is to minimize Seek Time (the time it takes for the disk head to move to the required cylinder).

To compare these algorithms, let’s use a standard example:

  • Total Cylinders: 0 to 199 (200 total tracks)
  • Current Head Position: 53
  • Request Queue: 98, 183, 37, 122, 14, 124, 65, 67

A. SSTF (Shortest Seek Time First)

SSTF selects the request that is closest to the current head position, minimizing the head movement for the very next step.

  • Path taken: Start at 53 → 65 → 67 → 37 → 14 → 98 → 122 → 124 → 183
  • Pros: Drastically reduces total seek time compared to standard First-Come, First-Served (FCFS).
  • Cons: Can lead to starvation. If new requests keep arriving near the current head position, requests far away (like 183) may never get serviced.

B. SCAN (The Elevator Algorithm)

The disk head starts at one end of the disk and moves toward the other end, servicing requests along the way. Crucially, it goes all the way to the end track (0 or 199) before reversing direction. (Assuming the head is currently moving toward 0)

  • Path taken: Start at 53 → 37 → 14 → 0 (end track) → 65 → 67 → 98 → 122 → 124 → 183
  • Calculation: (53 – 0) + (183 – 0) = 53 + 183 = 236 cylinders
  • Pros: Eliminates starvation.
  • Cons: Inefficient because it forces the head to travel all the way to the extreme edge (0 or 199) even if there are no pending requests there.

C. C-SCAN (Circular SCAN)

Designed to provide a more uniform waiting time. The head moves from one end to the other, servicing requests. When it reaches the end, it immediately returns to the beginning (0) without servicing any requests on the return trip, then starts servicing again. (Assuming the head is moving toward 199)

  • Path taken: Start at 53 → 65 → 67 → 98 → 122 → 124 → 183 → 199 (end track) → 0 (reset) → 14 → 37
  • Calculation: (199 – 53) + (199 – 0) + (37 – 0) = 146 + 199 + 37 = 382 cylinders
  • Pros: Provides a highly predictable, uniform wait time for all tracks.

D. LOOK

An optimized version of SCAN. The head moves in one direction servicing requests, but instead of going all the way to the edge (0 or 199), it looks ahead. If there are no more requests in that direction, it reverses immediately. (Assuming the head is moving toward 0)

  • Path taken: Start at 53 → 37 → 14 (reverses here because 14 is the lowest request) → 65 → 67 → 98 → 122 → 124 → 183
  • Calculation: (53 – 14) + (183 – 14) = 39 + 169 = 208 cylinders
  • Pros: Saves time by avoiding useless travel to empty disk edges.

E. C-LOOK (Circular LOOK)

An optimized version of C-SCAN. The head moves in one direction servicing requests. When it hits the last request in that direction, it jumps directly back to the lowest pending request on the other side (instead of going all the way to track 0). (Assuming the head is moving toward 199)

  • Path taken: Start at 53 → 65 → 67 → 98 → 122 → 124 → 183 (highest request) → 14 (lowest request) → 37
  • Calculation: (183 – 53) + (183 – 14) + (37 – 14) = 130 + 169 + 23 = 322 cylinders

2. Solid-State Drive (SSD) Management

Solid-State Drives (SSDs) do not have any moving parts; they use NAND flash memory. Because there is no disk head, mechanical disk scheduling algorithms like SCAN or LOOK are completely unnecessary for SSDs. Instead, SSD management focuses on handling the unique physical limitations of flash memory.

The Read/Write/Erase Disconnect

  • Data in an SSD is read and written in small units called Pages (e.g., 4 KB).
  • However, data can only be erased in larger blocks called Blocks (composed of multiple pages, e.g., 512 KB).
  • Garbage Collection: You cannot overwrite a page directly. To modify a page, the SSD must copy the valid pages from an old block to a fresh block, mark the old block as stale, and eventually erase the entire old block.

Flash Translation Layer (FTL)

The FTL is a micro-controller layer inside the SSD that acts as a bridge. It tricks the operating system into thinking it is talking to a traditional hard drive by mapping Logical Block Addresses (LBA) from the OS into changing Physical Block Addresses (PBA) on the flash chips.

Key SSD Management Techniques

  • Wear Leveling: NAND flash cells degrade after a certain number of write-and-erase cycles (P/E cycles). Wear leveling algorithms track usage and ensure that writes are evenly distributed across all physical blocks so that one part of the drive doesn’t fail prematurely.
  • Over-provisioning: SSDs keep a hidden pool of extra storage capacity (often 7–10% of the drive) that is invisible to the user. The FTL uses this extra space to swiftly manage garbage collection and replace failing blocks without degrading performance.
  • The TRIM Command: In traditional HDDs, deleting a file just marks its catalog entry as free space, leaving the raw data on the drive. For an SSD, this hurts performance during future overwrites. The OS issues a TRIM command to tell the SSD controller which pages contain deleted data, allowing the drive to wipe those pages during idle background garbage collection.