8/4/2020 CSC 452 – I/O Block Devices A device that stores data in fixed-sized blocks, each uniquely addressed, and can Jonathan Misurda be randomly accessed jmisurda@cs.arizona.edu 1 2 Character Devices Device Controllers Device that delivers or accepts a stream The electronic component of an I/O unit, of characters in contrast with the physical component. 3 4 Memory-Mapped I/O Interrupts Memory 0xFFF… I/O ports 0 Separate Memory-mapped I/O Hybrid: both Bus I/O & memory memory-mapped & space separate spaces 5 6 1
8/4/2020 Programmed I/O Polling copy_from_user (buffer, p, count); // copy into kernel buffer for (j = 0; j < count; j++) { // loop for each char while (*printer_status_reg != READY) ; // wait for printer to be ready User Printed Printed Printed *printer_data_reg = p[j]; // output a single character page page page } ABCD ABCD ABCD return_to_user(); EFGH EFGH EFGH A AB Kernel ABCD ABCD EFGH EFGH 7 8 Interrupt-Driven I/O DMA System Call copy_from_user (buffer, p, count); j = 0; enable_interrupts(); while (*printer_status_reg != READY) ; *printer_data_reg = p[0]; scheduler(); // and block user Interrupt Handler if (count == 0) { unblock_user(); } else { *printer_data_reg = p[j]; count--; j++; } acknowledge_interrupt(); return_from_interrupt(); 9 10 DMA I/O Request System Call copy_from_user (buffer, p, count); set_up_DMA_controller(); scheduler(); // and block user Interrupt Handler acknowledge_interrupt(); unblock_user(); return_from_interrupt(); 11 12 2
8/4/2020 Disks head sector Soft Timers platter Do we really need hardware timer track interrupts for preemption? cylinder surfaces spindle actuator 13 14 RAID CD-ROMs strip strip RAID 0 (Redundant Array of Inexpensive Disks RAID 1 (Mirrored copies) RAID 4 (Striped with parity) RAID 5 (Parity rotates through disks) 15 16 Disk Requests Disk Request Scheduling • Seek time Outside edge Inside edge • Rotational delay 8 51 73 77 100 133 140 175 • Actual transfer time read/write head position disk requests (cylinder in which block resides) Disk seek algorithm examples assume a request queue & head position (disk has 200 cylinders) Queue = 100, 175, 51, 133, 8, 140, 73, 77 Head position = 63 17 18 3
8/4/2020 First-Come, First-Served (FCFS) Read/write head start 100 Seek Distance 175 51 Total distance travelled to service a set of 133 8 disk requests 140 73 77 Seek distance = (100-63) + (175-100) + (175-51) + (133-51) + (133-8) + (140-8) + (140-73) + (77-73) = 646 cylinders 19 20 Shortest Seek Time First SCAN (Elevator Algorithm) Read/write head start Read/write head start 73 51 8 77 100 73 133 77 140 100 175 51 8 133 140 175 Seek distance = 12 + 43 + 8 + 73 + 4 + 23 + 33 + 7 + 35 = 238 cylinders Seek distance = 10 + 4 + 23 + 33 + 7 + 35 + 126 + 43 = 281 cylinders 21 22 LOOK C-SCAN Read/write head start Read/write head start 51 73 77 100 8 73 133 77 140 100 175 133 140 175 8 51 Seek distance = 12 + 43 + 65 + 4 + 23 + 33 + 7 + 35 = 222 cylinders Seek distance = 10 + 4 + 23 + 33 + 7 + 35 + 24 + 199 + 8 + 43 = 386 cylinders 23 24 4
8/4/2020 C-LOOK Read/write head start 73 77 100 133 140 175 8 51 Seek distance = 10 + 4 + 23 + 33 + 7 + 35 + 167 + 43 = 322 cylinders 25 5
Recommend
More recommend