Unit-5(5.
3)( I/O Management)
Input Output Management
Categories of I/O Devices
1) Human readable
–Used to communicate with the user
–Printers and terminals
2) Machine readable
–Used to communicate with electronic equipment
–Disk drives
–USB keys
–Sensors
–Controllers
3) Communication
–Used to communicate with remote devices
–Digital line drivers
–Modems
Differences in I/O Devices
•Data rate
–May be differences of several orders of magnitude between the data transfer rates
•Application
–Disk used to store files requires file management software
–Disk used to store virtual memory pages needs special hardware and software to support
it
•Complexity of control
•Data representation
–Encoding schemes
•Error conditions
–Devices respond to errors differently
Performing I/O
Three modes of transfer of device data, commands and status
•Programmed I/O
–Process is busy-waiting for the operation to complete
•Interrupt-driven I/O
–I/O command is issued
–Processor continues executing instructions
•Direct Memory Access (DMA)
–DMA module controls exchange of data between main memory and the I/O device
–Processor interrupted only after entire block has been transferred
Relationship Among Techniques
1
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
Evolution of the I/O Function
•Processor directly controls a peripheral device
•Controller or I/O module is added
–Processor uses programmed I/O without interrupts
–Processor does not need to handle details of external devices
•Controller or I/O module with interrupts
–Processor does not spend time waiting for an I/O operation to be performed
•Direct Memory Access
–Blocks of data are moved into memory without involving the processor
–Processor involved at beginning and end only
•I/O module is a separate processor
•I/O processor
–I/O module has its own local memory
–Its a computer in its own right
Direct Memory Address
•Processor delegates I/O operation to the DMA module
•DMA module transfers data directly to or form memory
•When complete DMA module sends an interrupt signal to the processor
DMA
2
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
DMA Configurations
3
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
Operating System Design Issues:
• Efficiency
– Most I/O devices extremely slow compared to main memory
– Use of multiprogramming allows for some processes to be waiting on I/O while
another process executes
– I/O cannot keep up with processor speed
– Swapping is used to bring in additional Ready processes which is an I/O operation
• Generality
– Desirable to handle all I/O devices in a uniform manner
– Hide most of the details of device I/O in lower-level routines
4
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
Model of I/O Operation:
I/O Buffering:
•Reasons for buffering
–Processes must wait for I/O to complete before proceeding
–Certain pages must remain in main memory during I/O
•Block-oriented
–Information is stored in fixed sized blocks
–Transfers are made a block at a time
–Used for disks and USB keys
•Stream-oriented
–Transfer information as a stream of bytes
–Used for terminals, printers, communication ports, mouse and other pointing
devices, and most other devices that are not secondary storage
Single Buffer
•Operating system assigns a buffer in main memory for an I/O request
5
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
•Block-oriented
–Input transfers made to buffer
–Block moved to user space when needed
–Another block is moved into the buffer
•Read ahead
–User process can process one block of data while next block is read in
–Swapping can occur since input is taking place in system memory, not user
memory
–Operating system keeps track of assignment of system buffers to user processes
•Stream-oriented
–Used a line at time
–User input from a terminal is one line at a time with carriage return signaling the
end of the line
–Output to the terminal is one line at a t
Double Buffer
•Use two system buffers instead of one
•A process can transfer data to or from one buffer while the operating system empties or
fills the other buffer
6
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
Circular Buffer
➢ When more than two buffers are used, the collection of buffers is itself referred to
as a circular buffer.
➢ Each individual buffer is one unit in a circular buffer
➢ Used when I/O operation must keep up with process
➢ In this, the data do not directly passed from the producer to the consumer because
the data would change due to overwriting of buffers before they had been
consumed.
➢ The producer can only fill up to buffer i-1 while data in buffer i is waiting to be
consumed.
Note:
Programmed I/O
Programmed I/O (PIO) refers to data transfers initiated by a CPU under driver
software control to access registers or memory on a device. The CPU issues a
command then waits for I/O operations to be complete. As the CPU is faster than
the I/O module, the problem with programmed I/O is that the CPU has to wait a
long time for the I/O module of concern to be ready for either reception or
7
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
transmission of data. The CPU, while waiting, must repeatedly check the status of
the I/O module, and this process is known as Polling. As a result, the level of the
performance of the entire system is degraded.
Programmed I/O basically works in these ways:
➢ CPU requests I/O operation
➢ I/O module performs operation
➢ I/O module sets status bits
➢ CPU checks status bits periodically
➢ I/O module does not inform CPU directly
➢ I/O module does not interrupt CPU
➢ CPU may wait or come back later
Interrupt-driven I/O
– I/O command is issued
– Processor continues executing instructions
– I/O module sends an interrupt when done
The CPU issues commands to the I/O module then proceeds with its normal work
until interrupted by I/O device on completion of its work.
For input, the device interrupts the CPU when new data has arrived and is ready to
be retrieved by the system processor.
For output, the device delivers an interrupt either when it is ready to accept new
data or to acknowledge a successful data transfer.
Although Interrupt relieves the CPU of having to wait for the devices, but it is still
inefficient in data transfer of large amount because the CPU has to transfer the data
word by word between I/O module and memory.
8
@Jeetesh Srivastava[UCER(CSE)]
Unit-5(5.3)( I/O Management)
Below are the basic operations of Interrupt:
➢ CPU issues read command
➢ I/O module gets data from peripheral whilst CPU does other work
➢ I/O module interrupts CPU
➢ CPU requests data
➢ I/O module transfers data
Direct Memory Access (DMA)
Direct Memory Access (DMA) means CPU grants I/O module authority to read
from or write to memory without involvement. DMA module controls exchange of
data between main memory and the I/O device. Because of DMA device can
transfer data directly to and from memory, rather than using the CPU as an
intermediary, and can thus relieve congestion on the bus. CPU is only involved at
the beginning and end of the transfer and interrupted only after entire block has
been transferred.
Interrupt –
In system programming, an interrupt is a signal to the processor emitted by
hardware or software indicating an event that needs immediate attention.
An interrupt alerts the processor to a high-priority condition requiring the
interruption of the current code the processor is executing.
What is IO subsystem in OS?
The I/O (input output) subsystem consists of the system bus, disk controllers,
disks, tape drives, and other I/O devices. The I/O database application utilizes the
Windows operating system I/O to read and write operations on disk.
9
@Jeetesh Srivastava[UCER(CSE)]