Principles Of Input / Output H/W• Two types of I/O devices- block, character• Block- can read blocks independently of one another • Hard disks, CD-ROMs, USB sticks • 512-32,768 bytes• Character-accepts characters without regard to block structure • Printers, mice, network interfaces• Not everything fits, e.g. clocks don’t fit• Division allows OS to deal with devices in device independent manner • File system deals with blocks Computer Engineering Department - MEFGI 2
Device Controllers• I/O unit has 2 components-mechanical, electronic (controller)• Controller is a chip with a connector which plugs into cables to device• Disk • Disk might have 10,000 sectors of 512 bytes per track • Serial bit stream comes off drive • Has preamble, 4096 bits/sector, error correcting code • Preamble has sector number, cylinder number, sector size….• Controller assembles block from bit stream, does error correction, puts into buffer in controller• Blocks are what are sent from a disk
Memory-Mapped I/O (a) Separate I/O ports and memory space. (b) Memory-mapped I/O. (c) Memory mapped data buffers and separate ports (Pentium)
Memory Mapped Advantages• Don’t need special instructions to read/write control registers.• Can write a device driver in C• Don’t need special protection to keep users from doing I/O directly. Just don’t put I/O memory in any user space
Memory Mapped Disadvantage• Can cache memory words, which means that old memory value (e.g. for port 4) could remain in cache• => have to be able to disable caching when it is worthwhile• I/O devices and memory have to respond to memory references• Works with single bus because both memory and I/O look at address on bus and decide who it is for ?• It gets harder with multiple buses
Interrupts Revisited How interrupts happens. Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires 8
Principles of I/O Software - Goals of I/OSoftware (1)• Device independence • programs can access any I/O device • without specifying device in advance · (floppy, hard drive, or CD-ROM)• Uniform naming • name of a file or device a string or an integer • not depending on which machine• Error handling • handle as close to the hardware as possible 9
Goals of I/O Software• Synchronous vs. asynchronous transfers • blocked transfers vs. interrupt-driven• Buffering • data coming off a device cannot be stored in final destination• Sharable vs. dedicated devices • disks are sharable • tape drives would not be 10
Device Drivers• Operating system and driver communication • Commands and data between OS and device drivers• Driver and hardware communication • Commands and data between driver and hardware• Driver responsibilities • Initialize devices • Interpreting commands from OS • Schedule multiple outstanding requests • Manage data transfers • Accept and process interrupts • Maintain the integrity of driver and kernel data structures
Check input parameters for validity, and translate them to devicespecific language• Check if device is free (wait or block if not)• Issue commands to control device• Write them into device controller’s registers• Check after each if device is ready for next (wait or block if not)• Block or wait for controller to finish work• Check for errors, and pass data to device-independent software• Return status information• Process next queued request, or block waiting for next
RAID Levels 0,1,2 Backup and parity drives are shown shaded.
RAID Backup and parity drives are shown shaded.