Lecture 33OutlineI/O Systems 1I/O Systems 2I/O Systems 3I/O Hardware 1I/O Hardware 2I/O Hardware 3I/O Hardware 4Application I/O Interface 1Application I/O Interface 2Application I/O Interface 3Application I/O Interface 4Application I/O Interface 5Application I/O Interface 6Application I/O Interface 7Application I/O Interface 8Kernel I/O Subsystem 1Kernel I/O Subsystem 2Kernel I/O Subsystem 3System Performance 1System Performance 2System Performance 3Monday, April 4 CS 470 Operating Systems - Lecture 33 1Lecture 33Schedule for rest of term posted.Optional project posted. Can be used to replace one project grade.Questions?Monday, April 4 CS 470 Operating Systems - Lecture 33 2OutlineI/O systemsI/O hardwareApplication I/O interfaceKernel I/O subsystemSystem performanceMonday, April 4 CS 470 Operating Systems - Lecture 33 3I/O SystemsMain jobs of a computerProcessingI/OOften the primary job is I/O with incidental processingWeb browsingDocument editingMonday, April 4 CS 470 Operating Systems - Lecture 33 4I/O SystemsI/O devices are diverse - mouse, disk, monitor - so various methods are needed to control them. Collectively, they are known as the I/O subsystem that separates the rest of the kernel form the complexities of managing I/O.Monday, April 4 CS 470 Operating Systems - Lecture 33 5I/O SystemsConflicting trendsIncreasing standardization of software/hardward interfaces makes is easier to incorporate new devicesI/O devices are becoming more diverse, unlike any previous devices.Details and oddities of differing devices are encapsulated in device drivers that allow the OS to provide a uniform device-access interface.Monday, April 4 CS 470 Operating Systems - Lecture 33 6I/O HardwareNot too much detail; covered in CS 320General categories:StorageTransmissionHuman interfaceSpecial I/O - sensors, actuatorsCommunicate with computer via port or busMonday, April 4 CS 470 Operating Systems - Lecture 33 7I/O HardwareController is a piece of electronics that operates a port, bus, or device.Sometimes a separate card, e.g. SCSI host adapter, network interface cardSometimes built into the device, e.g. disk controllerCommunication is through special I/O commands that write to registers at I/O port addresses or through memory-mapped I/O.E.g. PC graphics controller uses I/O ports for basic operations, but maps screen memory for direct writes.Monday, April 4 CS 470 Operating Systems - Lecture 33 8I/O HardwareInteraction (or handshaking) between devices is done through polling or interrupts.Polling is fast (read, mask, branch on 0), but wasted processing if event does not happen often.Interrupts only happen when events happen, but must have fast dispatch and ability to mask interrupts for critical sections or higher-priority interrupts.Monday, April 4 CS 470 Operating Systems - Lecture 33 9I/O HardwareDirect-memory access (DMA) controller is used to handle large transfers to memory so that CPU does not have to watch status bits and/or load data one word at a time.Monday, April 4 CS 470 Operating Systems - Lecture 33 10Application I/O InterfaceAs with other software-engineering problems, approach is to abstract and encapsulate behavior. Drivers provide a standardized set of functions - an interface - for various generic I/O devices.Lots of different classes of drivers.Monday, April 4 CS 470 Operating Systems - Lecture 33 11Application I/O InterfaceKernelKernel I/O SubsystemEIDEdevicedriverEthernetdevicedriverUSBdevicedriverPCI busdevicedrivergraphicsdevicedriverATAPIdevicedriverEIDEdevicecontrollerEthernetdevicecontrollerUSBdevicecontrollerPCI busdevicecontrollergraphicsdevicecontrollerATAPIdevicecontrollerhard disk networkmousekeyboardmemory monitor CD/DVDsoftwarehardware.........Monday, April 4 CS 470 Operating Systems - Lecture 33 12Application I/O InterfaceUnfortunately, each OS has its own standards for device-driver interface, so many devices ship with multiple drivers. Or are usable only with certain OS'sLess so now that many devices use USB for wired and Bluetooth for wireless interaction.Monday, April 4 CS 470 Operating Systems - Lecture 33 13Application I/O InterfaceDevices vary on many dimensionsdata transfer mode: character (e.g. terminal) vs. block (e.g. disk)access method: sequential (e.g. modem) vs. random (e.g. CD-ROM)transfer schedule: synchronous (e.g. tape) vs. asynchronous (e.g. keyboard)device speed: few bytes/sec (e.g. modem) vs. few gigabytes/sec (e.g. Ethernet)I/O direction: read-only (e.g. CD-ROM) vs. write-only (e.g., monitor) vs. read-write (e.g. disk)Monday, April 4 CS 470 Operating Systems - Lecture 33 14Application I/O InterfaceMost OS's support several general categories of devices.Block devices: read/write/seek operations. Sometimes raw I/O with direct access to controller. Sometimes direct I/O with no buffering or locking, but all other services.Character streams: single-character get/put operations. Buffered, concept of a line. Editing is built on top of these.Monday, April 4 CS 470 Operating Systems - Lecture 33 15Application I/O InterfaceNetwork devices use socket interface: create, bind, connect, listen, accept, selectClocks and timers: operations to get current time, get elapsed time, set timer to trigger operation X at time T. Interface is not standardized. Interrupt rates are 18-60 ticks/sec. Heavily used by the OS and real-time applications.Most OS's have an escape (or backdoor) command that will pass arbitrary commands to a device. E.g. Unix ioctl( ) system call.Monday, April 4 CS 470 Operating Systems - Lecture 33 16Application I/O InterfaceBlocking vs. non-blocking I/O. Most physical actions are asynchronous, but most system calls are blocking, since they are easier to understand and use.Some user-level processes need non-blocking I/O to do "simultaneous" I/O operations. E.g. keyboard and display, or video read and display.Monday, April 4 CS 470 Operating Systems - Lecture 33 17Application I/O InterfaceSometimes there is a difference between non-blocking and asynchronousNon-blocking: call attempts to perform an operation and returns in a short amount of time with indication of how far it got.Asynchronous: call returns immediately without waiting for I/O to complete. Notification is given when operation complete. (Event interrupt.)Threads can be used to provide simultaneous
View Full Document