170 likes | 192 Views
Disks and Storage Systems. CSE451 Andrew Whitaker. Big Picture. OS provides abstractions to allow physical HW resources to be shared CPU sharing with threads Memory sharing with virtual memory Disk sharing with files. Physical disk structure. Disk components platters surfaces tracks
E N D
Disks and Storage Systems CSE451 Andrew Whitaker
Big Picture • OS provides abstractions to allow physical HW resources to be shared • CPU sharing with threads • Memory sharing with virtual memory • Disk sharing with files
Physical disk structure • Disk components • platters • surfaces • tracks • sectors • cylinders • arm • heads sector track surface cylinder platter arm head
Disk Interface (as seen from the OS) • Disk exposes a contiguous array of logical block numbers • Internally, the disk maps these to cylinder, head, sector
Disk Size and Cost • Cost per gigabyte has plummeted • Now approximately $ .33 per Gigabyte
Disk trends • Disk capacity, 1975-1989 • doubled every 3+ years • 25% improvement each year • factor of 10 every decade • exponential, but far less rapid than processor performance • Disk capacity since 1990 • doubling every 12 months • 100% improvement each year • factor of 1000 every decade • 10x as fast an improvement as processor performance!
Components of Disk Access Latency • Seek time: moving the disk arm to the correct cylinder • Rotation time: waiting for the sector to rotate under head • Depends on rotation rate of disk • Transfer time: transferring data from surface into disk controller, and from there into main memory
Implications of Disk Performance • Large transfers are faster (per byte) than small transfers • Contiguous transfers are faster than scattered transfers • Contiguous transfer rate is 500X random access rate
Disk Partitions • Each physical disk can be split into logical disks, called partitions Partition 1 Partition 2 Partition 3 • Partition table provides sizes, types • Located in the first disk sector • Master Boot Record
Disks and File Systems • Each partition can contain a file system • Examples: NTFS, ext3, FFS • UNIX mount command shows file system partition mapping /dev/sda2 on / type ext3 (rw) /dev/sda5 on /usr type ext3 (rw,nodev) /dev/sda6 on /var type ext3 (rw,nosuid,nodev) /dev/sda7 on /tmp type ext3 (rw,nosuid,nodev) proc on /proc type proc (rw)
Accessing the Disk • Disk access is provided by a block device driver • Provides a function to enqueue a request Privileged User Apps File Systems Enqueue request Device Driver Read/write sectors Disk
What Happens on Enqueue Request? • OS maps from <partition, offset> to a logical block number • Make sure the offset is in bounds! • The request is added to a pending request queue • Common optimization: clustering • If the request is adjacent (on disk) to another request, merge them • Request scheduling • OS chooses an order for pending requests (see next slides) • Once the device is free, the device driver dispatches one or more pending requests
Disk Scheduling • Problem: Given a set of pending disk requests, choose an ordering • Goals (Quite possibly conflicting) • Maximize throughput • Minimize waiting • Provide fairness • Avoid starvation
Policy #1: First-come, First-serve • Disk requests are dispatched in the order they arrive • Performance of FCFS is highly dependent on the workload • Performs well if disk requests arrive in contiguous order • Performs poorly if requests arrivals are scattered across disk
Policy #2: Shortest-seek-time-first • Schedule the request that is closest to the current head position • Advantage: much better performance than FCFS • Disadvantage: bias, starvation • Requests in the middle cylinders get better service • Requests in outer cylinders can starve
Policy #3: SCAN Scheduling • Head continuously moves back and forth across the disk • Sometimes called “elevator algorithm” • Advantages: starvation-free, reasonable performance, easy to implement (sort)
Looking Ahead: File Systems • One proposal: use disk partitions for files • Use one disk partition per file • Is this a good idea? Why or why not? foo.txt bar.txt zag.txt