DOC PREVIEW
U of I CS 241 - Lawrence Angrave

This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 241 Spring 2007System Programming3/14/07 CS241 © 2007 LA, RHC and YZ, AllRights Reserved1I/Os, DevicesCS 241 Lecture 24Lawrence AngraveS: Ch 11[482-500,513-516 ]2Administration3OverviewBasic I/O hardware ports, buses, devices and controllersI/O Software Interrupt Handlers, Device Driver, Device-Independent Software, User-Space I/O SoftwareImportant concepts Three ways to perform I/O operations Polling, interrupt and DMAs4Hardware or Software?Is the following component software orhardware? Device controllerIs the following component software orhardware? Device driver5DevicesDevices Storage devices (disk, tapes) Transmission devices (network card, modem) Human interface devices (screen, keyboard,mouse) Specialized device (joystick)6•Why are keyboard and mouse are the slowest?•Why Gigabit Ethernet and graphics display arethe fastest?7Device-Computer/Device-DeviceCommunicationPhysically: via signals over a cable or through airLogically: via a connection point - port (e.g.,Serial port)Multiple devices are connected via a bus A common set of wires and a rigidly definedprotocol that specifies a set of messages that canbe sent on the wires8Device ControllerI/O units typically consist of A mechanical component: device itself An electronic component----the device controller oradapter.Interface between controller and device is a verylow level interface.Example: Disk's controller converts the serial bit stream,coming off the drive into a block of bytes, andperforms error correction.9I/O ControllerDisk controller implements the disk side of the protocol thatdoes: bad error mapping, prefetching, buffering,cachingController has registers for data and controlCPU and controllers communicate via I/O instructions and registers Memory-mapped I/O10I/O Ports4 registers - status, control, data-in, data-out Status - states whether the current command iscompleted, byte is available, device has an error,etc Control - host determines to start a command orchange the mode of a device Data-in - host reads to get input Data-out - host writes to send outputSize of registers - 1 to 4 bytes11Memory-Mapped I/O (1)(a) Separate I/O and memory space(b) Memory-mapped I/O(c) Hybrid12Memory-Mapped I/O (2)(a) A single-bus architecture(b) A dual-bus memory architecture133 Ways to Perform I/OPollingInterruptDMA14PollingPolling - use CPU to Busy wait and watch status bits Feed data into a controller register 1 byte at a time EXPENSIVE for large transfersNot acceptable except small dedicated systems notrunning multiple processesReal life analogy? Check the status the cookie being baked in the oven Your laundry machine15InterruptsConnections between devices and interrupt controller actually useinterrupt lines on the bus rather than dedicated wires16Host-controller interface: InterruptsCPU hardware has the interrupt report line that the CPUsenses after executing every instruction device raises an interrupt CPU catches the interrupt and saves the state (e.g.,Instruction pointer) CPU dispatches the interrupt handler interrupt handler determines cause, services the device andclears the interruptWhy interrupts?Real life analogy for interrupt An alarm sets off when the food/laundry is ready So you can do other things in between17Support for InterruptsNeed the ability to defer interrupt handling duringcritical processingNeed efficient way to dispatch the proper device Interrupt comes with an address (offset in interruptvector) that selects a specific interrupt handlingNeed multilevel interrupts - interrupt priority level18Interrupt HandlerAt boot time, OS probes the hardware buses to determine what devices are present install corresponding interrupt handlers into theinterrupt vectorDuring I/O interrupt, controller signals that deviceis ready19Other Types of InterruptsInterrupt mechanisms are used to handle widevariety of exceptions: Division by zero, wrong address Virtual memory paging System calls (software interrupts/signals, trap) Multi-threaded systems20Direct Memory Access (DMA)Direct memory access (DMA) Assists in exchange of data between CPU and I/Ocontroller CPU can request data from I/O controller byte by byte –but this might be inefficient (e.g. for disk data transfer) Uses a special purpose processor, called a DMAcontrollerReal life analogy Hire a helper---housekeeper21DMA-CPU ProtocolUse disk DMA as an exampleCPU programs DMA controller, sets registers to specifysource/destination addresses, byte count and controlinformation (e.g., read/write) and goes on with otherworkDMA controller proceeds to operate the memory busdirectly without help of main CPU – request from I/Ocontroller to move/write data to memory addressDisk controller transfers data to main memoryDisk controller acknowledges transfer to DMA controller22Direct Memory Access (DMA)Operation of a DMA transfer23DMA IssuesHandshaking between DMA controller and thedevice controllerCycle stealing DMA controller takes away CPU cycles when ituses CPU memory bus, hence blocks the CPUfrom accessing the memoryIn general DMA controller improves the totalsystem performance24DiscussionTradeoffs between Programmed I/O Interrupt-driven I/O I/O using DMAWhich one is the fastest for a single I/O request?Which one gives the highest throughput?25I/O Software LayersLayers of the I/O Software System26Device DriversLogical position of device drivers is shown hereCommunications between drivers and device controllers goes overthe bus27Device DriversDevice-specific code to control an IO device, is usually written bydevice's manufacturer Each controller has some device registers used to give itcommands. The number of device registers and the nature ofcommands vary from device to device (e.g., mouse driver acceptsinformation from the mouse how far it has moved, disk driver has toknow about sectors, tracks, heads, etc).A device driver is usually part of the OS kernel Compiled with the OS Dynamically loaded into the OS during executionEach device driver handles one device type (e.g., mouse) one class of closely related devices (e.g., SCSI disk driver to handlemultiple disks of different sizes and different speeds.).Categories: Block devices Character devices28Functions in Device DriversAccept abstract read and write requests from thedevice-independent layer above;Initialize the device;Manage power requirements


View Full Document

U of I CS 241 - Lawrence Angrave

Documents in this Course
Process

Process

28 pages

Files

Files

37 pages

File I/O

File I/O

52 pages

C Basics

C Basics

69 pages

Memory

Memory

23 pages

Threads

Threads

14 pages

Lecture

Lecture

55 pages

C Basics

C Basics

24 pages

Signals

Signals

27 pages

Memory

Memory

45 pages

Threads

Threads

47 pages

Threads

Threads

28 pages

LECTURE

LECTURE

45 pages

Threads

Threads

30 pages

Threads

Threads

55 pages

Files

Files

37 pages

SIGNALS

SIGNALS

22 pages

Files

Files

37 pages

Threads

Threads

14 pages

Threads

Threads

13 pages

Load more
Download Lawrence Angrave
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lawrence Angrave and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lawrence Angrave 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?