5I O Management
5I O Management
5I O Management
Introduction
So far, we have studied how resources like processor and main memory are managed. We
shall now examine the I/O management. Humans interact with machines by providing
information through I/O devices. Also, much of whatever a computer system provides as on-line
services is essentially made available through specialized devices such as screen displays,
printers, keyboards, mouse, etc. Clearly, management of all these devices can affect the
performance of a system. For this reason, input output management also becomes one of the
primary responsibilities of an operating system. In this chapter we shall examine the role of
operating systems in managing IO devices.
Objectives
➢ Explore the structure of an operating system’s I/O subsystem
➢ Discuss the principles of I/O hardware and its complexity
➢ Provide details of the performance aspects of I/O hardware and software
I- Input/output Hardware
a- I/O devices
There exists a wide variety classified as follows:
➢ Communication devices
Input only (keyboard, mouse, joystick)
Output only (printer, display)
Input/output (network card)
➢ Storage devices
Input/output (disk, tape)
Input only (CD-ROM)
b- Characteristics of I/O Devices
It is a function of host CPU architecture. It can be through special I/O instructions or through
memory-mapped I/O registers.
➢ Special I/O instructions are used in kernel mode only and when there is a separated
I/O address space.
➢ With Memory-mapped I/O control registers,
• Each register has a physical memory address
• Writing to data register is output
• Reading from data register is input
• Writing to control register causes action
• Can be mapped to user-level virtual memory
Polling is used when device and controller are relatively quick to process an I/O operation.
The following operations are performed by the device driver:
▪ Gains access to device
▪ Initiates I/O operation
▪ Loops testing for completion of I/O operation
▪ If there are more I/O operations, repeat
➢ Interrupt-Driven I/O (Programmed I/O with interrupt)
Here, CPU is responsible for Moving characters to/from controller buffer, but Interrupt signal
informs CPU when I/O operation completes. The Interrupt vector is used to dispatch interrupt to
the correct handler.
Interrupt-Driven I/O Cycle
➢ Efficiency: Do not allow I/O operations to become system bottleneck ( Especially for
slow devices)
➢ Device independence: isolate OS and application programs from device specific
details and peculiarities
➢ Uniform naming: support a way of naming devices that is scalable and consistent
➢ Error handling: isolate the impact of device errors, retry where possible, provide
uniform error codes (Errors are abundant in I/O)
➢ Buffering: provide uniform methods for storing and copying data between physical
memory and the devices
➢ Uniform data transfer modes: synchronous and asynchronous, read, write, ..
➢ Controlled device access: sharing and transfer modes
➢ Uniform driver support: specify interfaces and protocols that drivers must adhere to
c- I/O Subsystem
I/O system calls encapsulate device behaviors in generic classes; Device-driver layer hides
differences among I/O controllers from kernel. I/O subsystem signals process when I/O
completed. Device Drivers accept command from application (get/put character, read/write
block, send/receive packet) and Interact with (hardware) device controller to carry out command.
➢ Blocking: process suspended until I/O completed. It is easy to use and understand ,
and insufficient for some needs
➢ No blocking: I/O call returns as much as available. It is implemented via multi-
threading. It returns quickly with count of bytes read or written
A User process may accidentally or purposefully attempt to disrupt normal operation via illegal
I/O instructions. Consequently, All I/O instructions are defined to be privileged and I/O must be
performed via system calls. Memory-mapped and I/O port memory locations must be protected
too.
Kernel keeps state information for I/O components, including open file tables, network
connections, character device state…
Many complex data structures to track buffers, memory allocation, “dirty” blocks.