Chapter 5: I/O SystemsInput/OutputHow fast is I/O hardware?Device controllersMemory-Mapped I/OHow is memory-mapped I/O done?Direct Memory Access (DMA) operationHardware’s view of interruptsI/O software: goalsProgrammed I/O: printing a pageCode for programmed I/OInterrupt-driven I/OI/O using DMALayers of I/O softwareInterrupt handlersWhat happens on an interruptDevice driversDevice-independent I/O softwareWhy a standard driver interface?Buffering device inputAnatomy of an I/O requestDisk drive structureDisk drive specificsDisk “zones”Disk “addressing”Building a better “disk”RAIDs, RAIDs, and more RAIDsCD-ROM recordingStructure of a disk sectorSector layout on diskSector interleavingWhat’s in a disk request?Disk request schedulingDisk scheduling algorithmsFirst-Come-First Served (FCFS)Shortest Seek Time First (SSTF)SCAN (elevator algorithm)C-SCANC-LOOKHow to pick a disk scheduling algorithmWhen good disks go bad…Clock hardwareMaintaining time of dayDoing multiple timers with a single clockSoft timersCharacter-oriented terminalsBuffering for inputSpecial terminal charactersSpecial output charactersMemory-mapped displayHow characters are displayedInput softwareOutput software for WindowsSkeleton of a Windows programSkeleton of a Windows program (cont’d)Character outlines at different point sizesX WindowsArchitecture of the SLIM terminal systemThe SLIM Network TerminalPower Management (1)Power management (2)Power Management (3)Power Management (4)Chapter 5: I/O SystemsChapter 52CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Input/OutputPrinciples of I/O hardwarePrinciples of I/O softwareI/O software layersDisksClocksCharacter-oriented terminalsGraphical user interfacesNetwork terminalsPower managementChapter 53CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)How fast is I/O hardware?Device Data rateKeyboard 10 bytes/secMouse 100 bytes/sec56K modem 7 KB/secPrinter / scanner 200 KB/secUSB 1.5 MB/secDigital camcorder 4 MB/secFast Ethernet 12.5 MB/secHard drive 20 MB/secFireWire (IEEE 1394) 50 MB/secXGA monitor 60 MB/secPCI bus 500 MB/secChapter 54CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Device controllersI/O devices have componentsMechanical component Electronic componentElectronic component controls the deviceMay be able to handle multiple devicesMay be more than one controller per mechanical component (example: hard drive)Controller's tasksConvert serial bit stream to block of bytesPerform error correction as necessaryMake available to main memoryChapter 55CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Memory-Mapped I/OSeparateI/O & memoryspace0xFFF…0MemoryI/O portsMemory-mapped I/O Hybrid: bothmemory-mapped &separate spacesChapter 56CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)How is memory-mapped I/O done?Single-busAll memory accesses go over a shared busI/O and RAM accesses compete for bandwidthDual-busRAM access over high-speed busI/O access over lower-speed busLess competitionMore hardware (more expensive…)CPU Memory I/OCPU Memory I/OThis port allows I/O devicesaccess into memoryChapter 57CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Direct Memory Access (DMA) operationChapter 58CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Hardware’s view of interruptsBusChapter 59CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)I/O software: goalsDevice independencePrograms can access any I/O device No need to specify device in advance Uniform namingName of a file or device is a string or an integerDoesn’t depend on the machine (underlying hardware)Error handlingDone as close to the hardware as possibleIsolate higher-level softwareSynchronous vs. asynchronous transfersBlocked transfers vs. interrupt-drivenBufferingData coming off a device cannot be stored in final destinationSharable vs. dedicated devicesChapter 510CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Programmed I/O: printing a pagePrintedpageABCDEFGHKernel UserAPrintedpageABCDEFGHABCDEFGHABPrintedpageABCDEFGHABCDEFGHChapter 511CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Code for programmed I/Ocopy_from_user (buffer, p, count); // copy into kernel bufferfor (j = 0; j < count; j++) { // loop for each char while (*printer_status_reg != READY) ; // wait for printer to be ready *printer_data_reg = p[j]; // output a single character}return_to_user();Chapter 512CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Interrupt-driven I/Ocopy_from_user (buffer, p, count);j = 0;enable_interrupts();while (*printer_status_reg != READY) ;*printer_data_reg = p[0];scheduler(); // and block userif (count == 0) { unblock_user();} else { *printer_data_reg = p[j]; count--; j++;}acknowledge_interrupt();return_from_interrupt();Code run by system callCode run at interrupt timeChapter 513CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)I/O using DMAcopy_from_user (buffer, p, count);set_up_DMA_controller();scheduler(); // and block useracknowledge_interrupt();unblock_user();return_from_interrupt();Code run by system callCode run at interrupt timeChapter 514CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Layers of I/O softwareUser-level I/O software & librariesDevice-independent OS softwareDevice driversInterrupt handlersHardwareOperatingsystem(kernel)UserChapter 515CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)Interrupt handlersInterrupt handlers are best hiddenDriver starts an I/O operation and blocksInterrupt notifies of completionInterrupt procedure does its taskThen unblocks driver that started itPerform minimal actions at interrupt timeSome of the functionality can be done by the driver after it is unblockedInterrupt handler mustSave regs not already saved by interrupt hardwareSet up context for interrupt service procedureDLXOS: intrhandler (in dlxos.s)Chapter 516CS 1550, cs.pitt.edu (originaly modified by Ethan L. Miller and Scott A. Brandt)What happens on an interruptSet up stack for interrupt
View Full Document