A computer has three primary functions: input, output, and processing. In many cases, input/output is the most essential function, while processing is secondary. For example, when browsing a web page or editing a file, the primary concern is entering or reading information rather than calculating the answer. The primary role of the operating system in computer input/output is to manage and organize all I/O operations and I/O devices. This tutorial discusses the various uses of input and output devices in operating systems.

Overview of Input / Output System

One of the main challenges operating system designers face is managing different devices connected to the computer. This is because input/output (I/O) devices come in various types, each with different functions and speeds (e.g., mouse, hard disk, CD-ROM). As a result, the I/O subsystem is created in the operating system's kernel to manage these devices separately from the rest of the system. This helps to simplify the process of managing I/O devices.

I/O Hardware

Computers use different types of devices to perform various functions. The storage devices can be classified into disks, tapes, transmission devices (such as network interface cards and modems), and human interface devices (such as screens or keyboards).

Devices communicate with the computer's operating system by transferring signals through a cable or wirelessly. The peripheral devices connect to the machine through ports, such as a serial port. When devices use a set of wires or cables, it is called a "bus." A bus comprises a collection of wires and a well-defined protocol specifying messages that can be sent on the wires.

Operating System Using I/O Port

An I/O port usually consists of four different registers. These are (1) status, (2) control, (3) data-in, and (4) data-out registers.

  • The data-in register is read by the host to get input.
  • The data-out register is written by the host for sending output.
  • The status register holds bits that the host can read.
  • The control register is written by the host to start a command or change the mode of any device.
  • The data registers are usually 1 to 4 bytes in size. Some controllers have FIFO chips, which hold several bytes of input or output data for expanding the controller's capacity beyond the data register's size.


Interacting with the host and a controller can be complex for the operating system, but handshaking is straightforward. To illustrate handshaking, let's assume that two bits coordinate the producer-consumer relationship between the controller and the host. The controller uses the busy bit in the status register to indicate its state.

The host marks output through a port, with the controller using handshaking like:

  1. The host frequently reads the busy bit till that bit gets clear.
  2. The host then sets the write bit in the command register and writes a byte to the data-out register.
  3. The host then puts the command-ready bit.
  4. As the controller notices that the command-ready bit has been set, it sets the busy bit.
  5. The controller then reads the command register. It reads the data-out register to get the byte and performs the I/O to the device.
  6. The controller clears the command-ready bit and then clears the error bit within the status register to indicate that the device I/O succeeded.

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram