Unformatted text preview:

I/O Management 1I/O ManagementCPU vs I/O speed• CPU speeds continue to increase, and new CPUs have multiple processing elements on the same chip• A large amount of data can be processed very quickly• Problem in the transfer of data to CPU or even memory in a reasonable amount of time so that CPU has some work to doat all timeClassification of devices• Human readable – monitor, keyboard, mouse• Machine readable – disk/tape drives, sensors, controllers, actuators• Communication – modems, routers• Devices may be classified further even within classes by– Data rate∗ Some devices may not need to be very fast, for example keyboard to enter data∗ Graphics displays can always use a faster interface– Application– Complexity of control– Unit of transfer– Data representation– Error conditions• OS controls all I/O devices• Preferable to have the same interface for all I/O devices (device independence)Organization of I/O function• Programmed I/O– Under direct control of CPU– CPU issues a command on behalf of a process to an I/O module– CPU then waits for the operation to be completed before proceeding• Interrupt driven I/O– CPU issues a command on behalf of a process to an I/O module– If the I/O instruction is nonblocking, CPU continues to execute next instruction[s] from the same process– If the I/O instruction is blocking, OS takes over, suspends the current process, and assigns CPU to another process• Direct memory access (DMA)– DMA module controls exchange of data between memory and an I/O module– CPU sends a request to transfer a block of data to the DMA module and is interrupted only after the entire block hasbeen transferred– DMA module takes over control of system bus to perform the transfer– CPU initiates the I/O by sending the following information to DMA moduleI/O Management 2∗ Request type – read or write; using the read or write control line between the CPU and DMA module∗ Address of the I/O device, on the data line∗ Starting location in memory for read/write; communicated on data lines and stored by DMA module in itsaddress register∗ Number of words to read/write; communicated on data lines and stored in the data count register– DMA may ignore the paging circuitry and access the address bus directly to transfer several disk sectors in a singleI/O operation∗ This requires the requested buffers to be located in contiguous page framesI/O device• Any I/O device is hosted by one and only one bus• Bus type affects the internal design of I/O device as well as its handling by the kernel• I/O bus– Data path connecting a CPU to an I/O device– Intel x86 uses 16 of the address pins to address I/O devices and 8/16/32 of data pins to transfer data– I/O bus connected to an I/O device by a hierarchy of hardware components, including I/O ports, interfaces, anddevice controllers• I/O ports– Every device connected to the I/O bus has its own set of I/O addresses– In the IBM PC architecture, I/O address space has up to 216 8-bit I/O ports∗ Two consecutive 8-bit ports may be regarded as a single 16-bit port, starting at an even address∗ Two consecutive 16-bit ports may be regarded as a single 32-bit port, starting at an address divisible by 4Device drivers• Device drivers interact with the rest of the kernel through a specific interface• Abstract interfaces– An interface is a collection of routines and data structures that operate in a well-defined way– Network device drivers have to provide certain routines to operate on particular data structures– Generic layers of code using the services (interface) of lower layers of specific code– Network layer is generic and supported by device specific code that conforms to a standard interface• Advantages of extra layer between hardware and applications1. Makes programming easier; users do not have to study low-level programming characteristics of hardware devices– Device-specific code can be encapsulated in a specific module2. Increases system security; kernel can check accuracy of request at the interface level before attempting to satisfy it3. Unifrom interface makes programs more portable; programs compiled and executed correctly on every kernel thatoffers the same set of interfaces– Vendors can add new devices without access to kernel source– Kernel deals with all devices in a uniform way– Possible to load/unload a driver as per needs; plug-and-playI/O Management 3Communicating with device files• Device files– Represent physical devices– Possibly used for both input and output– Need a mechanism for device drivers in the kernel to receive output from process to send to device– Typically achieved by a function like device_write• What if you need to communicate with the device itself?– Serial port connected to a modem– Above scheme will allow you to write data to modem and receive data from modem∗ Write either modem commands or data to be sent through phone line∗ Read response to modem command or data received through phone line– What to do when you need to talk to the serial port itelf?∗ Send the rate at which data is sent/received• ioctl – I/O Control– Every device can have its own ioctl commands– ioctl function called with three parameters1. File descriptor of appropriate device2. ioctl number3. A parameter of type long so you can use a cast to use it to pass anything– ioctl number∗ Encodes the major device number, type of ioctl, command, and type of parameter∗ Usually created by a macro call (_IO, _IOR, _IOW, or _IOWR in a header fileBuffer cache• System gathers requests to write to and read from the disk in chunks• Helps with reduction of overhead associated with the operation• In some applications (databases), system may need to access the data that was just written; buffer cache helps improveperformance in such cases• Caching– Use of available physical memory as cache for hard disk and other block devices– Disk access much slower than memory, making disk a bottleneck in system performance– Unix defers writing to disk as long as possible∗ Data read previously from disk and no longer used by any process stays in RAM∗ There is a good chance that new process will require data read from or written to disk by terminated processes∗ When process asks to access a disk, kernel first checks that the data is already in cache; if it is (cache hit),kernel can service the request


View Full Document

UMSL CS 4760 - I - O Management

Documents in this Course
Load more
Download I - O Management
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 I - O Management 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 I - O Management 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?