Operating Systems 11/8/2018 Characteristics of I/O Devices • Data transfer mode – block vs. character Disk Storage • Access method – sequential vs. random • Transfer schedule – synchronous vs. and File Systems asynchronous • Sharing mode – dedicated vs. sharable CS 256/456 • Device speed – latency, seek time, transfer rate, Dept. of Computer Science, University occupancy/delay between operations of Rochester • I/O direction – R, W, R/W 11/8/2018 CSC 2/456 1 11/8/2018 CSC 2/456 2 Recap: Disk Storage Disk Management • Disk drive • Formatting – mechanical parts (cylinders, tracks, sectors) and how they move to access disk data – Header: sector number etc. – electronic part (disk controller main) exposes a one- – Footer/tail: ECC codes dimensionally addressable set of blocks – Gap – large seek/rotation time – Initialize mapping from logical block number to defect- free sectors • Logical disk partitioning – One or more groups of cylinders – Sector 0: master boot record loaded by BIOS firmware, which contains partition information – Boot record points to boot partition 11/8/2018 CSC 2/456 3 11/8/2018 CSC 2/456 4 CSC 256/456 1 Operating Systems 11/8/2018 Disk Drive – Mechanical Parts Disk Structure Cylinder • Disk drives are addressed as large 1- dimensional arrays of logical blocks, (set of tracks) Cylinder Track where the logical block is the smallest unit of transfer. (set of tracks) • The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially. – Sector 0 is the first sector of the first track on the outermost cylinder. – Mapping proceeds in order through Multi-surface Disk Disk Surface Cylinders that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders 11/8/2018 CSC 2/456 5 11/8/2018from outermost to innermost.CSC 2/456 6 Disk Performance Characteristics https://en.wikipedia.org/wiki/Hard_d 12 isk_drive 10 Improvement of HDD characteristics over time • A disk operation has three Started with Developed to 8 Parameter Improvement (1957) (2017) major components 6 [13 Capacity 3.75 megabytes [14] 3.73-million-to- ] 14 terabytes [15] – Seek – moving the heads 4 (formatted) one 2.1 cubic 68 cubic 3 [16][ [17] to the cylinder 2 Physical volume 3 [c][6] inches(34 cm ) 56,000-to-one feet(1.9 m ) d] Seek Seek time(millisecond) 0 containing the desired Seek timeSeek (millisecond) distance 2,000 pounds(910 2.2 ounces (62 g)[ Weight 15,000-to-one[18] sector kg)[6] 16] 2.5 ms to 10 ms; Average access approx. about RW RAM – Rotation – rotating the time 600 milliseconds[6] 200-to-one[19] dependent 60 desired sector to the US$9,200 per US$0.032 per 300-million-to- Price megabyte gigabyte by [22] disk head [20] [21] one 40 (1961) 2015 1.3 terabits per – Transfer – sequentially 2,000 bits per squ 650-million-to- Data density [23] square inch in [25] 20 are inch [24] one moving data to or from A Seagate SCSI drive 2015 c. 2,500,000 hrs An IBM SCSI drive c. 2000 hrs disk [27] 0 Average lifespan [citation needed] (~285 years) 1250-to-one Starting transfer address MTBF [26] Readthroughput(MB/sec) Transfer throughput (MB/sec) MTBF 11/8/2018 CSC 2/456 7 11/8/2018 CSC 2/456 8 CSC 256/456 2 Operating Systems 11/8/2018 Disk Scheduling FCFS (First-Come-First-Serve) • Disk scheduling – choose from outstanding disk requests when the disk is ready for a new request – can be done in both disk controller and the operating system – Disk scheduling non-preemptible • Goals of disk scheduling – overall efficiency – small resource consumption for completing disk I/O workload – fairness – prevent starvation • Illustration shows the total head movement is 640. • Starvation? 11/8/2018 CSC 2/456 9 11/8/2018 CSC 2/456 10 SSTF (Shortest-Seek-Time-First) SCAN • The disk arm starts at one end of the disk, and moves toward the • Selects the request with the minimum seek time from the current other end, servicing requests until it gets to the other end, where head position. the head movement is reversed and servicing continues. • SSTF scheduling is a form of SJF scheduling. • Sometimes called the elevator algorithm. • Illustration shows the total head movement is 236. • Illustration shows the total head movement is 208. Starvation? Starvation? 11/8/2018 CSC 2/456 11 11/8/2018 CSC 2/456 12 CSC 256/456 3 Operating Systems 11/8/2018 C-SCAN (Circular-SCAN) C-LOOK • Provides a more uniform wait time than SCAN. • Variation of C-SCAN • The head moves from one end of the disk to the other. servicing • Arm only goes as far as the last request in each direction, then requests as it goes. When it reaches the other end, however, it reverses direction immediately, without first going all the way to immediately returns to the beginning of the disk, without servicing the end of the disk. any requests on the return trip. Starvation? 11/8/2018 CSC 2/456 13 11/8/2018 CSC 2/456 14 Deadline Scheduling in Linux Concurrent I/O • A regular elevator-style scheduler similar to C-LOOK • Consider two request handlers in a Web server • Additionally, all I/O requests are put into a FIFO queue with an – each accesses a different stream of sequential data (a file) on disk; expiration time (e.g., 500ms) – each reads a chunk (the buffer size) at a time; does a little CPU • When the head request in the FIFO queue expires, it will be processing; and reads the next chunk executed next (even if it is not next in line according to C-LOOK). • What happens? • A mix of performance and fairness. A thread/process A thread/process A thread/process Timeline Disk I/O CPU or waiting for I/O 11/8/2018 CSC 2/456 15 11/8/2018 CSC 2/456 16 CSC 256/456 4 Operating Systems 11/8/2018 How to Deal with It? Two Disks: Disk Striping • Aggressive prefetching • Anticipatory scheduling [Iyer & Druschel, SOSP 2001] • Blocks divided into subblocks – at the completion of an I/O request, the disk scheduler will wait a bit (despite the fact that there is other work to do), in anticipation • Subblocks stored on different disks that a new request with strong locality will be issued; schedule another request if no such new request appears before timeout – included in Linux 2.6 Disk 1 Disk 2 CPU 11/8/2018 CSC 2/456 17 18 Two Disks: Mirroring Multiple Disks: Parity Block • Have one disk contain parity bits of • Make a copy of each block on each disk blocks on other devices • Provides redundancy • Provides redundancy without full copy Disk 1 Disk 2 Disk 1 Disk 2 Disk 3 CPU CPU 19 20 CSC 256/456 5 Operating Systems 11/8/2018 Exploiting Concurrency Solid State Drives • RAID: Redundant Arrays of Independent Disks • No mechanical component (moving parts) – RAID 0: data striping at block level, no redundancy • Lower energy requirements – RAID 1: mirrored disks (100% overhead) • Speed – RAID 2: bit-level striping with parity bits, synchronized writes – Reads and writes in the order of 10s of – RAID 3: data striping at the bit level with parity disk, microseconds (reading faster than writing) synchronized writes – Erase on the order of a millisecond – RAID 4: data striping at block level with parity disk • Finite number of erase and write cycles, – RAID 5: scattered parity requiring what is called “wear leveling” – RAID 6: handles multiple disk failures 11/8/2018 CSC 2/456 21 11/8/2018 CSC 2/456 22 Flash Memory (Based on Charge) File Systems • Based on floating-gate transistor • A File system is the OS abstraction for storage resources – File is a logical storage unit in the OS abstract interface for storage resources • Extension of address space (temporary files) • Non-volatile storage that survives the execution of an individual program (persistent files) – Directory is a logical “container” for a group of files 11/8/2018 CSC 2/456 23 11/8/2018 CSC 2/456 24 CSC 256/456 6 Operating Systems 11/8/2018 Operations Supported File System Issues • Create – associate a name with a file • File naming and other attributes: • Delete – remove the file – name, size, access time, sharing/protection, • Rename – associate a new name with a file location • Open – create cached context that is associated • Intra-file structure implicitly with future reads and writes – None - sequence of words, bytes • Write – store data in a file – Complex Structures • Read – access the data associated with a file • records/formatted document/executable • Close – discard cached context • File system organization: efficiency of disk access • Seek – random access to any record or byte • Concurrent access: allow multiple processes to read/write • Map – place in address space for convenience (memory- • Reliability: integrity in the presence of failures based loads and stores), speed; disadvantages: lengths • Protection: sharing/protection attributes and access control that are not multiples of the page size, consistency with lists (ACLs) open/read/write interface 11/8/2018 CSC 2/456 25 11/8/2018 CSC 2/456 26 Naming Files Using Directory File Naming Structures • Fixed vs. variable length • Directory: maps names to files; directories may – Fixed: 8-255 characters themselves be files – Single level (flat): no two files may have the – Variable: length:value encoding same name • File extensions – system supported vs. – Two level: per-user single-level directory convention – Hierarchical: generalization of two level; each file system is assigned the root of a tree – Acyclic (or cyclic) graph: allow sharing of files across directories; hard versus soft (symbolic) links 11/8/2018 CSC 2/456 27 11/8/2018 CSC 2/456 28 CSC 256/456 7 Operating Systems 11/8/2018 Shared Files: Links File Types • File appears simultaneously in different • Control operations allowed on files directories • Use file name extensions to indicate type (in • File system is now a directed acyclic graph Unix, this is just a convention) (DAG) • Structured vs.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages19 Page
-
File Size-