0% found this document useful (0 votes)
0 views

Chapter 4 - Device management

Chapter 4 discusses device management in operating systems, covering categories of I/O devices, their characteristics, and data transfer rates. It explains buffering strategies to handle data flow and introduces Direct Memory Access (DMA) for efficient data transfer without CPU intervention. The chapter highlights the differences between block and character devices, as well as the operational details of parallel and serial communication methods.

Uploaded by

naemader
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Chapter 4 - Device management

Chapter 4 discusses device management in operating systems, covering categories of I/O devices, their characteristics, and data transfer rates. It explains buffering strategies to handle data flow and introduces Direct Memory Access (DMA) for efficient data transfer without CPU intervention. The chapter highlights the differences between block and character devices, as well as the operational details of parallel and serial communication methods.

Uploaded by

naemader
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

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.

• It must issue commands to the devices, catch interrupts,


and handle errors.
• It should also provide an interface between the devices
and the rest of the system that is simple and easy to use.

2
Categories of I/O devices
• I/O devices can be roughly divided into two categories: block
devices and character devices.

• A block device is one that stores information in fixed-size blocks,


each one with its own address.
– Common block sizes range from 512 to 65,536 bytes.

– All transfers are in units of one or more entire (consecutive) blocks.

– The essential property of a block device is that it is possible to read or


write each block independently.

– 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,

• which puts considerable pressure on the software to


perform well over many orders of magnitude in data
rates.

• Table in next slide shows the data rates of some common


devices.

• Most of these devices tend to get faster as time goes on.

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.

• For example, when a packet comes in from the network, the OS


does not know where to put,

• It has to store the packet somewhere and then examined it.

• This working principle is known as buffering.

• Also, some devices have severe real-time constraints (for example,


digital audio devices),

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 involves considerable copying and often has a major


impact on I/O performance.

• 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.

– One possible strategy for dealing with the incoming characters


is to have the user process do a read system call and block
waiting for one character.

– Each arriving character causes an interrupt.

– The interrupt-service procedure hands the character to the user


process and unblocks it.

– After putting the character somewhere, the process reads


another character and blocks again. 14
Direct memory access
• The CPU can request data from an I/O controller one byte at a
time, but doing so wastes the CPU’s time;

• So a different scheme, called DMA (Direct Memory Access) is


often used.

• 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.

• These include a memory address register, a byte count register, and


one or more control registers.

– 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),

– the transfer unit (byte at a time or word at a time), and the


number of bytes to transfer in one burst. 16
How DMA works ?
• To answer this question, let us first look at how disk reads occur when
DMA is not used.
• First the disk controller reads the block (one or more sectors) from the
drive serially, bit by bit, until the entire block is in the controller’s
internal buffer.
• Next, it computes the checksum to verify that no read errors have
occurred.
• When the operating system starts running, it can read the disk block
from the controller’s buffer a byte or a word at a time by executing a
loop, and
• With each iteration reading one byte or word from a controller device
register and storing it in main memory.
17
Operation of a DMA transfer

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.

• In a scatter-gather list, data is spread out over several blocks.

• These blocks can be of two types: data blocks and extension


blocks.

• A data block is simply a chunk of application-specific data, while


an extension block contains references to other blocks.

• Extension blocks can only be referenced from the last row in


another extension block.

20
• Any Question?

21

You might also like