Lecture 7 b IO IO devices q q
Lecture 7 b I/O
I/O devices q q q Device (mechanical hardware) Device controller (electrical hardware) Device driver (software)
Devices and their controllers Monitor Bus q Components of a simple personal computer
How to communicate with a device? q Hardware supports I/O ports or memory mapped I/O for accessing device controller registers and buffers
Wide performance range for I/O
Performance challenges: I/O hardware q q How to prevent slow devices from slowing down memory How to identify I/O addresses without interfering with memory performance
Hardware view of Pentium Structure of a large Pentium system
Performance challenges: I/O software q q How to prevent CPU throughput from being limited by I/O device speed How to prevent I/O throughput from being limited by CPU speed How to achieve good utilization of CPU and I/O devices How to meet the real-time requirements of devices
Programmed I/O q Polling/busy-waiting approach copy_from_user(buffer, p, count); for(i=0; i<count; i++){ while (*p_stat_reg != READY); *p_data_reg = p[i]; } return();
Interrupt driven I/O (b)
Interrupt-driven I/O q Asynchronous approach v v give device data, do something else! resume when device interrupts copy_from_user(buffer, p, count); enable_interrupts(); while (*p_stat_reg != READY); *p_data_reg=p[0]; scheduler(); if (count==0){ unblock_user(); } else { *p_data_reg = p[i]; count--; i++; } ack_interrupt(); return_from_interrupt();
DMA q Offload all work to a DMA controller v v v avoids using the CPU to do the transfer reduces number of interrupts DMA controller is like a co-processor doing programmed I/O copy_from_user(buffer, p, count); set_up_DMA_controller(); scheduler(); ack_interrupt(); unblock_user(); return_from_interrupt();
DMA
Software engineering-related challenges q How to remove the complexities of I/O handling from application programs v v q standard I/O APIs (libraries and system calls) generic across different device types How to support a wide range of device types on a wide range of operating systems v v standard interfaces for device drivers standard/published interfaces for access to kernel facilities
I/O Software: Device Drivers q Device drivers “connect” devices with the operating system v Typically a nasty assembly-level job • Must deal with hardware changes • Must deal with O. S. changes q Device drivers are typically given kernel privileges v Can bring down O. S. !
I/O Software design issues q Synchronous vs. asynchronous transfers v q Buffering v q Blocked transfers vs. interrupt-driven Data coming off a device cannot be stored in final destination Sharable vs. dedicated devices v v Disks are sharable Tape drives would not be
I/O software design issues q Device independence v q Uniform naming v v q programs can access any I/O device without specifying device in advance (floppy, hard drive, or CD-ROM) Name of a file or device a string or an integer not depending on which machine Shouldn’t depend upon the device Error handling v Handle as close to the hardware as possible
Devices as files q q Before mounting, v files on floppy are inaccessible After mounting floppy on b, v files on floppy are part of file hierarchy
Spare Slides
Disks
Disk geometry q Disk head, platters, surfaces
Disk geometry q CAV & CLV
RAID
RAID
CD-ROMs
Plastic technology q CDs v v q Approximately 650 Mbytes of data Approximately 74 minutes of audio DVDs v Many types of formats • DVD-R, DVD-ROM, DVD-Video v v v Single layer vs. multi-layer Single sided vs. double sided Authoring vs. non-authoring
Disk scheduling algorithms q Time required to read or write a disk block determined by 3 factors v v v Seek time Rotational delay Actual transfer time q Seek time dominates q Error checking is done by controllers
Disk scheduling algorithms q First-come first serve q Shortest seek time first q Scan back and forth to ends of disk q C-Scan only one direction q Look back and forth to last request q C-Look only one direction
Disk scheduling algorithms
Display hardware q PCI graphics card (traditional) v Map frame buffer into memory
Display hardware q Intel-based systems
Display hardware q Resolution v Determines the amount of pixels displayable and the # of colors that can be used • 1024*768*24 -bit color ~2 MBytes • 1600*1200*24 -bit color ~6 Mbytes • 1600*1200*(16 colors) ~1 Mbytes v q Usually double-buffered Data rate v v Determines refresh rate Monitor must be greater than what the video card is trying to display
X-terminals
X-terminals q Long past v v q X-terminals were great because of limited pixel depth Good way to share expensive resources Future v v v Great way to limit maintenance costs Great for basic applications X-terminals are getting killed by multimedia applications • DVD 740*480*24 -bit color 255 Mbps!!
Summary q q Mismash of I/O topics Readings: v q 5. 1 – 5. 1. 4, 5. 2, 5. 4 – 5. 4. 3, 5. 7. 1 Homework #4 – Due Wed. Dec. 1 v Chapter 4: • Problem # 23, 29 v Chapter 5: • Problem # 24
- Slides: 35