Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Chapter 13: I/O Systems
Overview I/O Hardware
Application I/O Interface Kernel I/O Subsystem
13.3 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Objectives
Explore the structure of an operating system’s I/O subsystem
Discuss the principles of I/O hardware and its complexity
Overview
I/O management is a major component of operating system design and operation
Important aspect of computer operation
I/O devices vary greatly
Various methods to control them
Performance management
13.5 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
I/O Hardware
One of the important jobs of an Operating System is to manage various I/O devices including
mouse, keyboards, disk drives, display adapters, USB devices, Analog-to-digital converter, On/off switch, network connections, audio I/O, printers etc.
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. I/O devices can be divided into two categories −
Block devices − A block device is one with which the driver communicates by sending entire
blocks of data. For example, Hard disks, USB cameras, Disk-On-Key etc.
Character devices − A character device is one with which the driver communicates by sending
I/O Hardware – Device Controller
Device drivers are software modules that can be plugged into an OS to handle a
particular device. Operating System takes help from device drivers to handle all I/O devices.
The Device Controller works like an interface between a device and a device driver. I/O
units (Keyboard, mouse, printer, etc.) typically consist of a mechanical component and an electronic component where electronic component is called the device controller.
There is always a device controller and a device driver for each device to communicate
13.7 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
I/O Hardware – Device Controller
Any device connected to the computer is connected by a plug and socket, and the socket
13.9 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
I/O Hardware – Device Controller
The CPU must have a way to pass information to and from an I/O device. There are
Polling
The process of periodically checking status bits to see if it is time for the next I/O
operation, is called polling.
Polling is the simplest way for an I/O device to communicate with the processor. The
I/O device simply puts the information in a Status register, and the processor must come and get the information. The processor is totally in control and does all the work.
The disadvantage of polling is that it can waste a lot of processor time because
13.11 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Interrupts
Overhead in a polling interface lead to the invention of interrupts to notify the
13.17 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
The OS could be designed such that new devices can be attached to the computer without the OS being rewritten with the help of Application I/O interface.
Application I/O Interface represents the structuring techniques and interfaces for the operating system to enable I/O devices to be treated in a standard, uniform way.
Application I/O Interface
Following are the characteristics of I/O interfaces with respected to devices.
Character-stream / block - A character-stream device transfers bytes in one by one
fashion, whereas a block device transfers a complete unit of bytes.
Sequential / random-access - A sequential device transfers data in a fixed order
determined by the device, random access device can be instructed to seek position to any of the available data storage locations.
Synchronous / asynchronous - A synchronous device performs data transfers with
known response time where as an asynchronous device shows irregular or unpredictable response time.
Sharable / dedicated - A sharable device can be used concurrently by several processes
or threads but a dedicated device cannot be used.
Speed of operation - Device speeds may range from a few bytes per second to a few
13.19 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Device Drivers: Device drivers are software modules that can be plugged into an OS to handle a particular device. Operating System takes help from device drivers to handle all I/O devices.
•Device driver, is generally written by the device's manufacturer and delivered along with the device on a CD-ROM.
A device driver performs the following jobs −
•To accept request from the device independent software above to it.
•Interact with the device controller to take and give I/O and perform required error handling
•Making sure that the request is executed successfully
13.21 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Kernel
− Kernel is the core part of
Linux. It is responsible for all major
activities of this operating system.
It consists of various modules and it
interacts
directly
with
the
underlying
hardware.
Kernel
provides the required abstraction
to hide low level hardware details
to system or application programs.
Kernel I/O Subsystem
Kernel I/O Subsystem is responsible to provide many services related to I/O.
Following are some of the services provided.
Scheduling −
Kernel schedules a set of I/O requests to determine a good order
in which to execute them. When an application issues a blocking I/O system
call, the request is placed on the queue for that device. The Kernel I/O
scheduler rearranges the order of the queue to improve the overall system
efficiency and the average response time experienced by the applications.
Buffering −
Kernel I/O Subsystem maintains a memory area known
13.23 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Kernel I/O Subsystem
Caching −
Kernel maintains cache memory which is region of fast
memory that holds copies of data. Access to the cached copy is more
efficient than access to the original.
Spooling and Device Reservation −
A spool is a buffer that holds output
for a device, such as a printer. The spooling system copies the queued
spool files to the printer one at a time.
Error Handling −
An operating system that uses protected memory can
13.25 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Transforming I/O requests to hardware operations: In order to transform an I/O request to a hardware operation, the CPU has to go through a couple of stages.
•When the CPU receives an I/O request, at first, it has to determine which device is holding the
file.
•As we know that, all file has a name, the name contains the address location of that file. So,
the file name is then transformed and arranged into the device representation.
•After that, the CPU goes to the exact location of the file according to the representation and
physically read data of the file from disk into buffer.
•When the buffering is over, the data is available to the user or the requesting process.
•The process or the user then has to control of that file. The user or the process can do
whatever it wants with that data, such as- edit it, delete it or whatever.
13.27 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition
Performance
I/O a major factor in system performance:
Context switches due to interrupts
Data copying
Improving Performance
Reduce number of context switches
Reduce data copying
Reduce interrupts by using large transfers, polling
Use DMA
Use smarter hardware devices
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition