Managing the various I/O devices is one of the important jobs of an operating system. The list of the I/O devices include the elements such as keyboards, touchpad, display adapters, mouse, disk drivers, LED, bit-mapped screen, USB devices, network connections, printers, audio I/O, on/off switch, analog-to-digital converter, etc.
The prime reason for the development of the I/O system in a computer is taking an application of the I/O request and sending it to the physical device. It is required to take back the response from the device and then to send it to the application. There are two categories of the input and output devices of the operating system. These are as follows-
- Block Devices- The devices which communicate with the driver by sending the complete block of data are called block devices. Some of the examples of the block devices are hard disks, USB cameras, disk-on-key etc.
- Character Devices- These types of devices in which the communication of the driver takes place by receiving and sending the single characters in the form of bytes or octets. The examples of the character devices are parallel ports, serial ports, sounds card and many more.
The software modules which are used to plug into the operating system for the process of handling a particular device are called device drivers. The device drivers help the operating system in the handling of all the input and output devices.
The controller of the device acts as an interface between the driver of the device and device. All the input and output units of the computer system which include printer, mouse, keyboard and many other devices consist of an electronic component as well as a mechanical component. Here, the device controller is the electronic component of the devices.
In the operating systems, there is always the availability of a device driver and a device controller. They are used for the communication process, whereas, the device controller can take charge of handling the multiple devices at the same time. The device controller is the interface, and that is why it takes one of the most important tasks of the computer system, i.e. conversion of the serial bit stream into the byte blocks. Also, it performs error correction whenever required.
The socket and the plug are used to connect the computer and the device. The socket here is connected to the controller of the device.
Synchronous and Asynchronous Input and Output devices
- Synchronous I/O- In this type of the process, the CPU waits for its execution to be done while the I/O are proceeding.
- Asynchronous I/O- It is the opposite of the synchronous input and output. Here, in this scheme, the execution of the central processing unit and the I/O proceeding takes concurrently.
Communication to I/O devices
There should be a way for the CPU in which it can pass the information to and from an Input and Output device. There is an availability of the approaches which are required to communicate with the device and the main processing unit of the computer system. These are-
- Memory Mapped I/O
- Special Instruction I/O
- Direct Memory Access (DMA)
- Memory-mapped I/O
In this approach of the input-output communication, the memory and input/output device shares the same address space. For the ease of transfer of the block data to and from memory without going through the CPU, there is a direct connection of the device and the specificcentral memory locations.
The memory gets the allocation of a buffer by the operating system while using the memory mapped I/O. Also, it informs the input and the output of the devices to be used to send the data to the CPU. There is an asynchronous operation of the I/O device with the CPU. In addition to this, the I/O devices interrupt the CPU at the time it is finished.
You can manipulate an I/O device and every instruction which accesses the memory. It is the prime advantage of the memory-mapped I/O method.
- Special Instruction I/O-
This method uses the instructions of the CPU which are made to control the I/O devices in particular. This special instruction allows various functions such as data to be sent to an I/O device or read it.
- Direct Memory Access(DMA)-
The device which is slow in the operation, as the keyboard results in the generation of the interrupt to the main CPU after the transfer of every bite. Most of the time of the operating system goes in handling the interrupt generated by the fast device. The disk is one of the examples of the fastdevices. DMA is the hardware which a typical computer uses for the reduction of the overhead.
In the direct access of the memory, the I/O module gets the grant by the CPU for reading from and writing into the memory without involvement. Controlling the exchange of the data between the I/O device and the main memory is one of the prime function of the direct memory access. The interruption of the data occurs after the transfer of the entire block. It is because the CPU is available for the access only at the commencement and the end of the transfer.
There is special hardware which the DMA needs for the transfer. It is called DMA controller (DMAC). Management of the data transfer and the arbitration of the access of the system bus is the responsibility of the hardware involved in the direct access of memory.
Polling vs Interrupts I/O
The computer should detect the arrival of any type of input. Pooling and the interrupts are the two ways in which this can be done. Allowing the processor for the dealing of the events which are not related to the current process is the primary function of these techniques.
For the communication of an input and output device with the processor, the simplest way is the polling system. Polling is the process of checking the status of the device and examine whether it is the correct time for the next operation of the input and output. Status register gets the information from the input and output device. After this, the processor must come and use it.
No device needs the attention. Every time it does, it has to wait for the next interrogated by the polling program. Most of the time of the processor goes in the management of the unnecessary polls,and it is the reason it is taken as an inefficient method.
Interrupt-driven method is an alternative method to deal with the input and output. When a microprocessor gets the signal from the device for the attention, it is called an interrupt.