Coupon Accepted Successfully!


I/O system

The two main jobs of a computer are I/O and processing. In many cases, the main job is I/O, and the processing is merely incidental. For instance, when we browse a web page or edit a file, our immediate interest is to read or type in some information; it is not to compute an answer. The role of the operating system in computer I/O is to manage and control I/O operations and I/O devices. The operating system provides interfaces to interact with the underlying hardware. These interfaces abstract away the detailed differences in I/O devices and provide a uniform way for interaction. The actual differences are encapsulated in kernel modules called device drivers that internally are custom tailored to each device. The purpose of the device-driver layer is to hide the differences among device controllers from the I/O subsystem of the kernel.
Devices vary in many aspects. Some of them are:
  • Character-stream or block - A character-stream device transfers bytes one by one, whereas a block device transfers a block of bytes as a unit.
  • Sequential or random-access - A sequential device transfers data in a fixed order that is determined by the device, whereas the user of a random-access device can instruct the device to seek to any of the available data storage locations.
  • Synchronous or asynchronous - A synchronous device is one that performs data transfers with predictable response times while an asynchronous device exhibits irregular or unpredictable response times.
  • Sharable or dedicated - A sharable device can be used concurrently by several processes or threads but a dedicated one cannot.
  • Speed of operation - Device speed range from a few bytes per second to a few gigabytes per second.
  • Read-write, read only, or write only - Some devices perform both input and output, but others support only one data direction.
Kernels provide many services related to I/O. Several services - I/O scheduling, buffering, caching, spooling, and error handling - are provided by the kernel's I/O subsystem, and build on the hardware and device-driver infrastructure.
I/O scheduling - To schedule a set of I/O requests means to determine a good order in which to execute them. Scheduling can improve overall system performance, can share device access fairly among processes, and can reduce the average waiting time for I/O to complete. Operating-system developers implement scheduling by maintaining a queue of requests for each device. When an application issues a blocking I/O system call, the request is placed on the queue for that device. The I/O scheduler rearranges the order of the queue to improve the overall system efficiency and the average response time experienced by applications
Buffering - A buffer is a memory area that stores data while they are transferred between two devices or between a device and an application. Buffering is done for three reasons. One reason is to cope with a speed mismatch between the producer and consumer of a data stream. Secondly to adapt between devices that have different data-transfer sizes. Third, to support copy semantics for application I/O.
Caching - A cache is region of fast memory that holds copies of data. Access to the cached copy is more efficient than access to the original.
Spooling - A spool is a buffer that holds output for a device, such as a printer, that cannot accept interleaved data stream. Although a printer can serve only one job at a time, several applications may wish to print their output concurrently, without having their output mixed together. The operating system solves this problem by intercepting all output to the printer. Each application's output is spooled to a separate disk file. When an application finishes printing, the spooling system queues the corresponding spool file for output to the 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 guard against many kinds of hardware and application-errors, so that a complete system failure is not the usual result of each minor mechanical glitch. As a general rule, an I/O system call will return 1 bit of information about the status of the call, signifying either success or failure.

Test Your Skills Now!
Take a Quiz now
Reviewer Name