INPUT OUTPUT DEVICE MANAGEMENT
One of the important jobs of an Operating System is to manage various I/O devices including
mouse, keyboards, touch pad, disk drives, display adapters, USB devices, Bit-mapped screen,
LED, Analog-to-digital converter, On/off switch, network connections, audio I/O, printers etc.
The I/O management subsystem
An I/O subsystem comprises of I/O devices and their corresponding driver software. Drivers hide
the peculiarities of specific hardware devices from the users. An Operating System manages the
communication between user and device drivers.
I/O operation means read or write operation with any file or any specific I/O device.
Operating system provides the access to the required I/O device when required
An I/O system is required to take an application I/O request and send it to the physical device, then take
whatever response comes back from the device and send it to the application. An Operating System
manages device communication via their respective drivers. It does the following activities for
device management −
i) Controls all the input and output of the computer system.
ii) The Operating System should also provide an interface between the devices and the
rest of the system that is simple and easy to use. To the extent possible, the interface
should be the same for all devices (device independence).
iii) For the enforcement of security, the most important things that the I/O management
subsystem does is: managing the transfer of data and enforcing access controls on
data while it is being transferred.
iv) The Operating System must issue commands to the devices, catch interrupts, and
handle errors.
v) Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
vi) Decides which process gets the device when and for how much time.
vii) Allocates the device in the efficient way.
viii) De-allocates devices.
There are several input output devices such as keyboards, mouse, monitor, clocks etc.
Hardware devices engaged in I/O can be categorized into:-
Human Readable: Responsible for interaction with the user. Examples include: printers,
keyboard, mouse, video display
Machine readable: Provision of system local hardware functionality examples include: disk
drives, USB keys, sensors, controllers
Communication/Network devices: Provision of communication support eg modems, WLAN
stick, network cards.
Miscellaneous (e.g. clocks and timers), provide current time, elapsed time, timer etc, they cover
odd aspects of I/O such as clocks and timers.
I/O DEVICES
I/O devices can be roughly divided into two categories:
i. Block devices
ii. Character devices.
A block device is one that stores information in fixed-size blocks, each one with its own address.
Common block sizes range from 512 bytes to 32,768 bytes. All transfers are in units of one or more entire
(consecutive) blocks. The essential property of a block device is that it is possible to read or write each
block independently of all the other ones. Hard disks, CD-ROMs, and USB sticks are common block
devices.
A character device delivers or accepts a stream of characters, without regard to any block structure. It is
not addressable and does not have any seek operation. Printers, network interfaces, mice (for pointing),
and most other devices that are not disk-like can be seen as character devices.
There are great differences across classes and even substantial differences within each class that a
uniform consistent approach (generality) to I/O difficult to achieve. Devices differ in a number of areas:
i) Data rate: There may be differences of several orders of magnitude between the data transfer
rates.
ii) Application: The use to which a device is put has an influence on the software and policies
in the operating system and supporting utilities. For example, a disk used for files requires the
support of file management software. A disk used as a backing store for pages in a virtual
memory scheme depends on the use of virtual memory hardware and software. Furthermore,
these applications have an impact on disk scheduling algorithms
As another example, a terminal may be used by an ordinary user or a system administrator. These uses
imply different privilege levels and perhaps different priorities in the operating system.
iii) Complexity of control: A printer requires a relatively simple control interface. A disk is
much more complex. The effect of these differences on the operating system is filtered to
some extent by the complexity of the I/O module that controls the device.
iv) Unit of transfer: Data may be transferred as a stream of bytes or characters (e.g., terminal
I/O) or in larger blocks (e.g., disk I/O).
v) Data representation: Different data encoding schemes are used by different devices,
including differences in character code and parity conventions.
vi) Error conditions: The nature of errors, the way in which they are reported, their
consequences, and the available range of responses differ widely from one device to another.
This diversity makes a uniform and consistent approach to I/O, both from the point of view of the
operating system and from the point of view of user processes, difficult to achieve.
DEVICE CONTROLLER
The Device Controller works like an interface between a device and a device driver. I/O units typically
consist of a mechanical component and an electronic component.
It is often possible to separate the two portions to provide a more modular and general design. The
electronic component is called the device controller or adapter. On personal computers, it often takes the
form of a chip on the parentboard or a printed circuit card that can be inserted into a (PCI) expansion slot.
The mechanical component is the device itself.
I/O SOFTWARE
DEVICE DRIVER
Each device connected to the computer needs device specific code for controlling – device driver written
by device manufacturer and delivered along with the device. Each OS needs its own device driver for
each device.
A device driver is an operating system module that deals directly with a device or an I/O module.
OR
Device drivers are software modules that can be plugged into an OS to handle a particular
device. Operating System gets help from device drivers to handle all I/O devices.
It is the lowest level of software to interact with the I/O hardware.
It contains all device dependent code for one type of hardware unit. Direct communication with the
device hardware. The loaded drivers become part of the running operating system image.
There is always a device controller and a device driver for each device to communicate with the
Operating Systems. A device controller may be able to handle multiple devices. As an interface
its main task is to convert serial bit stream to block of bytes, perform error correction as
necessary.
Any device connected to the computer is connected by a plug and socket, and the socket is
connected to a device controller
Synchronous vs asynchronous I/O
Synchronous I/O − In this scheme CPU execution waits while I/O proceeds
Asynchronous I/O − I/O proceeds concurrently with CPU execution
Communication to I/O Devices
The CPU must have a way to pass information to and from an I/O device. There are three
approaches available to communicate with the CPU and Device.
Special Instruction I/O
Memory-mapped I/O
Direct memory access (DMA)
The Evolution of the I/O Function
As one moves along the evolutionary path, more and more of the I/O function is performed without
processor involvement. The central processor is increasingly relieved of I/O related tasks, improving
performance.
1. The processor directly controls a peripheral device. This is seen in simple microprocessor
controlled devices
2. A controller, or I/O module is added. The processor uses programmed I/O without interrupts.
3. Interrupts are employed and the processor need not spend time waiting for an I/O operation to be
performed, thus increasing efficiency.
4. The I/O module is given direct control of memory via DMA. It can now move a block of data to
or from memory without involving the processor.
5. The I/O module (I/O channel) is enhanced to become a separate processor (An IO channel is
primarily a small computer to basically handle I/O from multiple sources. It ensures that I/O
traffic is smoothed out.)
6. The I/O module (I/O processor) has a local memory of its own. With this architecture, a large set
of I/O devices can be controlled, with minimal processor involvement.
Techniques for I/O operation
When the processor is executing a program and encounters an instruction relating to I/O, it executes that
instruction by issuing a command to the appropriate module.
1. PROGRAMMED I/O MODULE
This is where the I/O module performs the requested action and then sets the appropriate bits in the I/O
status register but takes no further action to alert the processor. In particular, it does not interrupt the
processor.
2. MEMORY MAPPED I/O
When using memory-mapped I/O, the same address space is shared by memory and I/O devices.
The device is connected directly to certain main memory locations so that I/O device can transfer
block of data to/from memory without going through CPU.
While using memory mapped IO, OS allocates buffer in memory and informs I/O device to use
that buffer to send data to the CPU. I/O device operates asynchronously with CPU, interrupts
CPU when finished.
The advantage to this method is that every instruction which can access memory can be used to
manipulate an I/O device. Memory mapped IO is used for most high-speed I/O devices like
disks, communication interfaces.
3. DIRECT MEMORY ACCESS (DMA)
Slow devices like keyboards will generate an interrupt to the main CPU after each byte is
transferred. If a fast device such as a disk generated an interrupt for each byte, the operating
system would spend most of its time handling these interrupts. So a typical computer uses direct
memory access (DMA) hardware to reduce this overhead.
No matter whether a CPU does or does not have memory-mapped I/O, it needs to address the device
controllers to exchange data with them. The CPU can request data from an I/O controller one byte at a
time but doing so wastes the CPU's time, so a different scheme, called DMA (Direct Memory Access) is
often used. The operating system can only use DMA if the hardware has a DMA controller, which most
systems do. Sometimes this controller is integrated into disk controllers and other controllers, but such a
design requires a separate DMA controller for each device. More commonly, a single DMA controller is
available (e.g., on the parentboard) for regulating transfers to multiple devices, often concurrently.
The DMA module controls exchange of data between main memory and an I/O module.
It is a more efficient technique when large volumes of data are to be moved. The DMA function can be
performed by a separate module on the system bus or it can be incorporated into an I/O module.
The DMA unit is capable of mimicking the processor and indeed of taking over control of the system bus
just like a processor. It needs to do this to transfer data to and from memory over the system bus.
When the processor wishes to read or write a block of data, it issues a command to the DMA module by
sending to the DMA module the information listed below and then the processor continues with its work
because it has delegated this I/O operation to the DMA module:
Whether a read or write is requested, using read or write control line between the processor and
the DMA Module.
The address of the I/O device involved, communicated on the data line.
The starting location in memory to read from or write to, communicated on the data lines and
stored by the DMA module in its address register.
The number of words to be read or written, again communicated via the data lines and stored in
the data count register.
The DMA module transfers an entire block of data, one word at a time, directly to or from memory,
without going through the processor. When the transfer is complete, the DMA module sends an interrupt
signal to the processor. Thus the processor is involved only at the beginning and at the end of the transfer.
(Evolution 4)
The DMA module needs to take control of the bus to transfer data to and from memory. Because of this
competition for bus usage there may be times when the processor needs the bus and must wait for the
DMA module. This is not an interrupt and the processor does not have to save a context and do something
else. Rather the processor pauses for one bus cycle. The overall effect is that the processor executes more
slowly during a DMA transfer when the processor access to the bus is required.
OPERATING SYSTEM Design Objectives
Two objectives are paramount in designing the I/O facility: efficiency and generality.
Efficiency is important because I/O operations often form a bottleneck in a computing system. We see
that most I/O devices are extremely slow compared with main memory and the processor. One way to
tackle this problem is multiprogramming, which, as we have seen, allows some processes to be waiting on
I/O operations while another process is executing. However, even with the vast size of main memory in
today’s machines, it will still often be the case that I/O is not keeping up with the activities of the
processor. Swapping is used to bring in additional ready processes to keep the processor busy, but this in
itself is an I/O operation. Thus, a major effort in I/O design has been schemes for improving the
efficiency of the I/O.
The other major objective is generality. In the interests of simplicity and freedom from error, it is
desirable to handle all devices in a uniform manner. This statement applies both to the way in which
processes view I/O devices and the way in which the operating system manages I/O devices and
operations. Because of the diversity of device characteristics, it is difficult in practice to achieve true
generality.
What can be done is to use a hierarchical, modular approach to the design of the I/O function. This
approach hides most of the details of device I/O in lower-level routines so that user processes and upper
levels of the operating system see devices in terms of general functions, such as read, write, open, close,
lock, unlock.
RAID (Redundant Array of Independent Disks)
• Set of physical disk drives viewed by the operating system as a single logical drive
• Data are distributed across the physical drives of an array
• Redundant disk capacity is used to store parity information which provides recoverability from disk
failure