OS - Chapter - 6 - Input Output Management
OS - Chapter - 6 - Input Output Management
Meti Dejene
[email protected]
Haramaya University
Chapter 6 – Input Output Management
Introduction
The Processor and memory are not the only resources that the operating system must
manage.
Input/Output (I/O) devices also interact heavily with the operating system.
point, or port.
If devices share a common set of wires over which a set of messages are sent and
However, because I/O devices vary so widely in their function and speed, varied
Device drivers are specialized low-level software programs designed to allow the
Device drivers translate generic commands from the OS into commands that the
hardware understands.
They provide a standardized interface for the OS to send requests and receive responses
Device controller is a hardware unit on the motherboard attached to the I/O bus
and responsible for handling the incoming and outgoing signals of a device.
operations.
Interaction with I/O Devices
How does the processor give commands and data to a controller to accomplish an I/O
transfer?
The short answer is that the controller has one or more registers for data and control
When data is transmitted from an external device to the computer system, it's initially
When the CPU needs to send data to an external device, it's placed in the "data out"
3. The status register contains bits that can be read by the host.
These bits provide information about the device's current state, such as whether the
current command has completed, whether a byte is available to be read from the
4. The control register can be written by the host to start a command or to change the
mode of a device.
Cont.
The processor communicates with the controller by reading and writing bit patterns in
these registers.
The controller indicates its state through the busy bit in the status register.
The controller sets the busy bit when it is busy working and clears the busy bit when it is
To set a bit means to write a 1 into the bit and to clear a bit means to write a 0 into it.
In such a way, it accepts commands from the operating system, for example, to read
2. Sequential or random access devices: A sequential device transfers data in a fixed order
determined by the device, whereas the user of a random-access device can instruct the
available.
Basically, it is reading the status register over and over in a loop until the busy bit
becomes clear.
Interrupts
Rather than to poll repeatedly for an I/O completion, it may be more efficient to arrange
for the hardware controller to notify the CPU when the device becomes ready for service.
This mechanism that enables a device to notify the CPU when it is ready for service is
called an interrupt.
These interrupts signify that output has completed, or that input data are available, or
When the CPU detects that a controller has asserted a signal on the interrupt-request line,
the CPU performs a state save and jumps to the interrupt-handler routine.
The interrupt handler determines the cause of the interrupt, performs the necessary
processing, performs a state restore, and executes a return from interrupt instruction to
We say that the device controller raises an interrupt by asserting a signal on the interrupt
request line, the CPU catches the interrupt and dispatches it to the interrupt handler, and
Programmed I/O (PIO) is a basic method of transferring data between the CPU
and external devices where the CPU directly controls data transfer between itself
expensive general-purpose processor to watch status bits and to feed data into a controller
As an alternative, computers avoid burdening the main CPU with PIO by offloading some of
this work to a special-purpose hardware component called a direct memory access (DMA)
This allows the CPU to focus on executing instructions and performing computations rather
the CPU sets up the DMA controller by programming it with the necessary
Once the data transfer is finished, the DMA controller signals the CPU (often through
data/jobs for devices (such as printers) in a Spool until the device is ready to accept
the job.
A spool is a dedicated queue on a disk that holds output for a device, such as a
Spooling is more about managing device access and queuing tasks for devices that
A buffer is a temporary storage area, often in RAM, that temporarily holds data
application.
Buffering helps manage the flow of data efficiently and optimize data transfer,
differs.
Caching
Caching refers to the mechanism of temporarily storing frequently accessed data and files
Cache is a small high-speed memory located near the CPU that temporarily stores copies
of frequently accessed used data based on past access patterns to expedite future
access.
Caching is designed to reduce memory access latency and improve system performance
by bridging the speed gap between slower, larger storage (like hard drives) and the faster
So, when an application requests data from a file, the OS checks if it is available in the
cache first.
A "cache hit" occurs when the requested data is found in the cache, resulting in
faster access.
A "cache miss" happens when the required data is not in the cache, necessitating
Most computers have hardware clocks and timers that provide three basic functions:
The OS uses timers (e.g. Programmable Interval Timer ) to schedule tasks or processes
based on time slices or deadlines.
The scheduler uses this mechanism to generate an interrupt that will preempt a
process at the end of its time slice.