Chapter 4 - Device management
Chapter 4 - Device management
Contents:
Introduction including Categories of I/O
devices and data rates of some common
devices.
Characteristics of parallel and serial devices
Buffering strategies
Direct memory access
1
Introduction
• In addition to providing abstractions such as processes,
address spaces, and files,
– an operating system also controls all the computer’s I/O
(Input/Output) devices.
2
Categories of I/O devices
• I/O devices can be roughly divided into two categories: block
devices and character devices.
– Hard disks, Blu-ray discs, and USB sticks are common block devices.
3
Categories of I/O devices, …
• A character device delivers or accepts a stream of
characters, without regard to any block structure.
• It is not addressable and does not have any seek
operation.
• Printers, network interfaces, mice (for pointing), and most
other devices can be seen as character devices.
• The classification scheme for I/O is not perfect.
– Some devices do not fit in;
– Clocks, for example, are not block addressable nor do
they generate or accept character streams.
4
Devices’ data transfer rate
• I/O devices cover a huge range in speeds,
5
Data rates of some common devices:
6
Characteristics of parallel and serial devices
• Characteristics of Parallel Ports:
– Transfer multiple bits at a time.
– It can send/receive 8 bits/1 byte at a time.
– It contains 25 female pins.
– Connects devices like printer, external HDD, scanners,
etc. to the computer.
– The most common parallel port is the printer port, Its
other name is Centronics port.
– Data travel speed is 150 kilobits per second.
7
Example of Parallel Ports:
• The most common type of parallel port is a
printer port (e.g., a Centronics port that transfers
8 bits at a time).
8
Parallel communication through parallel device
9
Characteristics of parallel and serial devices
• Characteristics of the serial or USB port:
– Serial port used for external modems and older
computer mouse.
– Two versions - 9 pin, 25 pin model
– Data travels at 115 kilobits per second
• Universal Serial Bus (USB) port:
– can connect almost all the common devices such as a printer,
keyboard, mouse, speakers, etc.
– Generally, 2-3 such ports are present in the computer system.
– Its speed is much faster than the serial port; rates 14 Mbps.
– Devices connected to this port get power from the USB port
itself. 10
Communication Demo: parallel and serial
11
Buffering strategies
• Often data that come off a device cannot be stored directly in their
final destination.
12
Buffering strategies, …
• So the data must be put into an output buffer in advance to
decouple the rate at which the buffer is filled from the rate at
which it is emptied, in order to avoid buffer under-runs.
• Buffering is also an issue, both for block and character devices, for
a variety of reasons.
13
Buffering strategies, …
• Consider a process that wants to read data from an ADSL
(Asymmetric Digital Subscriber Line) modem.
• We assume that the CPU accesses all devices and memory via a
single system bus that connects the CPU, the memory, and the I/O
devices.
• The operating system can use only DMA if the hardware has a
DMA controller, which most systems do. 15
Direct memory access, …
• No matter where it is physically located, the DMA controller has
access to the system bus independent of the CPU.
• It contains several registers that can be written and read by the CPU.
– The control registers specify the I/O port to use, the direction of
the transfer (reading from the I/O device or writing to the I/O
device),
18
How DMA works ?, …. Cont’
• To initiate a DMA copy operation, software first writes a physical address to the
DMA source and DMA destination registers.
• The address in the DMA destination register is the start address where the data will
be copied and is always a contiguous block.
• The DMA source register can hold the address to either a contiguous block or to a
scatter-gather (SG bit) list -> (writes data from multiple buffers to a single data stream, or
reads data from a stream into multiple buffers)
• The SG bit in the DMA control register determines how the DMA device interprets
the data at the source address.
• To start the copy operation, the software writes the DMA control register with a
nonzero value for the EN(Enable DMA) bit, the SWT(Software Transfer Trigger ) bit, and
the TS(Transfer size) field.
• Upon completion the DMA controller sets the TC(Transfer Complete ) bit and, if
the ECI(Enable Completion Interrupt) bit is set, raises an interrupt.
19
How DMA works ?, …. Cont’
• If the device is configured in scatter-gather mode (SG bit set), the
copy procedure works as follows.
20
• Any Question?
21