Computer Science Related Others Courses AvailableThe Best Codder.blogspot.com

I/O Hardware , Device Controllers , Synchronous vs asynchronous I/O , Special Instruction I/O , Memory-mapped I/O , Direct Memory Access (DMA) , Polling and Interrupts I/O

A computer system operates on multiple devices. An important service provided by an OS is I/O management. Some common I/O devices are mouse, keyboard,

 

Operating System I/O Hardware

A computer system operates on multiple devices. An important service provided by an OS is I/O management. Some common I/O devices are mouse, keyboard, touchpad, USB devices, Bit-mapped screen, LED, On/off switch, network connections, audio I/O, printers etc.

An I/O system takes an I/O request and sends it to the physical device. It then sends the response from the device to the application. There are two types of I/O devices:

  • Block devices: The driver communicates with this device by sending to it blocks of data.
  • Character devices: The driver communicates by sending and receiving single characters with the help of this device.

Categories of I/O devices

Following are the three categories of I/O devices:

1. Human-readable: These are suitable for communicating with the user. For example, mouse, printer, keyboard, etc.

2. Machine-readable: These are suitable for communicating with electronic equipment. For example disk and tape drives, sensors, etc.

3. Communication: Suitable for communicating with remote devices. For example digital line drivers, modems, etc.

Device Controllers

We can plug software modules into an operating system in order to handle a particular device. These modules are known as device drivers. They help the OS handle I/O devices. Interface between a device and device driver is called a device controller. An I/O unit consists of two components, namely, a mechanical component and an electronic component. This electronic component is known as a device controller.

Each device has a device controller and a device driver that helps communicate with the OS. A device controller handles multiple devices and converts a serial bit stream to a block of bytes, and performs error correction when necessary. Some device controllers are northbridge, southbridge, keyboard controller, and memory controller.

Synchronous vs asynchronous I/O

  • Synchronous I/O: In synchronous I/O, the CPU execution waits while I/O proceeds
  • Asynchronous I/O: In asynchronous I/O, I/O proceeds along with CPU execution

Communication to I/O Devices

There are three ways for a CPU to communicate with an I/O device. There are:

  • Special Instruction I/O
  • Memory-mapped I/O
  • Direct memory access (DMA)

Special Instruction I/O

This type uses CPU instructions specially tailored for controlling I/O devices. These instructions help send data to an I/O device and read data from an I/O device.

Memory-mapped I/O

In this type, the same address space is shared by memory and I/O devices. It allows the I/O devices to transfer blocks of data to/from memory without going through the CPU. Every instruction accessing the system memory can manipulate an I/O device. Thus, this I/O is used for high-speed I/O devices.

During this, the OS also allocates a buffer in the system memory and informs the I/O device to send data to the processor using that buffer. Thus, an I/O device operates asynchronously with the processor and interrupts it when done.

Direct Memory Access (DMA)

Slow I/O devices tend to generate an interrupt to the main CPU after the transfer of each byte. But if the same was the case with fast devices, then the OS would be stuck handling these interrupts. In order to avoid this situation, a computer uses DMA hardware.

When the CPU grants the I/O module the authority to read/write in the system memory, this is called direct memory access. The DMA module controls the exchange of data between the main memory and the I/O device without any interference from the CPU.

The DMA controller makes DMA possible. This manages data and transfers and adjudicates access to the system bus. It also helps in tracking the number of transferred bytes it has the knowledge about the source and destination pointers. It also has many settings such as I/O and memory types and interrupts and states for the CPU cycles.

Following are the steps followed by the OS to use DMA hardware:

1. The device driver transfers disk data to a buffer address X, as per instructions.
2. The disk controller transfers data to the buffer, as per instructions from the device driver.
3. Disk controller starts DMA transfer.
4. The disk controller sends each byte to the DMA controller.
5. After receiving bytes from the disk controller, the DMA controller transfers them to the buffer. It also increases the memory address and decreases counter C to zero.
6. After C becomes zero, the DMA interjects the CPU to signal transfer completion.

Polling and Interrupts I/O

There are two ways for a computer system to detect the arrival of any input, namely, polling and interrupts. Both techniques help the CPU deal with events that can happen at any time and that are not related to the running process.

Polling I/O

Polling is the process of checking the status of a device periodically and checking if it is time for the next I/O operation. It is the simplest way of communication where a status register collects information from the I/O so that the CPU can collect this information.

A device needs to wait to be interrogated by the polling program even though there is no other device needing attention currently. This makes it an inefficient method as it wastes the time of the CPU on irrelevant polls.

Interrupts I/O

In the interrupt-driven method, the device that requires attention sends a signal(interrupt) to the microprocessor. A device controller puts this interrupt signal on the bus. After the processor receives a signal, it saves the current state of the device and using the interrupt vector, invokes the required interrupt handler. After dealing with the device, the processor resumes its original task as if it was never interrupted in the first place.

Post a Comment

© Operating System . The Best Codder All rights reserved. Distributed by