Hard Drive Hardware

Addressing and Geometry
Hard drives expose a large number of sectors(blocks)
- Typically 512 or 4096 bytes(=page size -> easy to swap)
- Individual sector writes are atomic
- Multiple sectors writes may be interrupted(torn write)

Drive geometry
- Sectors arranged into tracks
- Cylinder is a particular track on multiple platters
- Tracks arranged in concentric circles on platters
- A disk may have multiple, double-sided platters

각속도: 각이 같으면 같은 속도
선속도: 각속도가 같으면 바깥쪽으로 갈수록 선속도가 빨라짐
seek -> arm으로 원하는 track을 찾는다.
Common Disk Interfaces
- ST-506 -> ATA -> IDE -> SATA
- Recent versions support Logical Block Addresses (LBA)
Small(=server) Computer System Interface
- Packet based, like TCP/IP
- Device translates LBA to internal format
- Transport independent
Types of Delay With Disks
Three types of delay
1. Rotational Delay
- Time to rotate the desired sector to the read head
- Related to RPM
2. Seek Delay
- Time to move the read head to a different track
3. Transfer time
- Time to read or write bytes
Track skew
- offset sectors so that sequential reads across tracks incorporate seek delay
How To Calculate Transfer Time



Sequential vs. Random Access

Caching
- Many disks incorporate caches (track buffer)
- Small amount of RAM (8,16, 32 MB)
- Read caching
- Reduces read delays due to seeking and rotation
- Write caching
- Write back cache: drive reports that writes are complete after they have been cached
- Write through cache: drive reports that writes are complete after they have been written to disk
- Today, some disks include flash memory for persistent caching (hybrid drives)
Disk Scheduling
First come, first serve (FCFS)
- Most basic scheduler, serve requests in order

Shortest seek time first (SSTF)
- minimize seek time by always selecting the block with the shortest seek time
- pros
- SSTF is optimal, and it can be easily implemented
- cons
- SSTF is prone to starvation

SCAN, otherwise known as the elevator algorithm
- Head sweeps across the disk servicing requests
in order

C-SCAN
- Like SCAN, but only service requests in one direction

C-LOOK
- Peek at the upcoming addresses in the queue
- Head only goes as far as the last request

Implementing Disk Scheduling
Where
- OS scheduling
- OS can implement SSTF or LOOK by ordering the queue by LBA
- However, the OS cannot account for rotation delay
- On-disk scheduling
- Disk knows the exact position of the head and platters
- Can implement more advanced schedulers (SPTF)
- But, requires specialized hardware and drivers
Command Queuing
- Feature where a disk stores of queue of pending read/write requests
- Disk may reorder items in the queue to improve performance
- E.g. batch operations to close sectors/tracks
- Supported by SCSI and modern SATA drives
- Tagged command queuing: allows the host to place constraints on command re-ordering
