Prepared By: Jerusalem Y.
Device Management 4/23/2019 1
Introduction
Abstracting device differences
Direct memory access
Buffering strategies
Recovery from failures
Device Management 4/23/2019 2
Device management is the process of managing the
implementation, operation and maintenance of a physical
and/or virtual device. It is a broad term that includes various
administrative tools and processes for the maintenance and
upkeep of a computing, network, mobile and/or virtual device.
An Operating System manages device communication via
their respective drivers.
It does the following activities for device management
1. Keeps tracks of all devices. Program responsible for this task
is known as the I/O controller.
2. Decides which process gets the device when and for how
much time.
3. Allocates the device in the efficient way.
4. De-allocates devices.
Device Management 4/23/2019 3
1. Monitor the status of all devices, including storage
drives, printers and other peripherals
2. Enforce pre-set policies on which process gets
which device for how long
3. Deal with the allocation of devices to processes
4. Deal with the de-allocation of devices to
processes, both at a temporary basis (e.g. when
the process is interrupted) and on a permanent
basis (e.g. when the process is completed).
Device Management 4/23/2019 4
Keyboard
Mouse
Monitor
Scanner
USB Ports
Webcam
Microphone
Printer
Device Management 4/23/2019 5
There are three main types of devices:
1. Dedicated Devices
2. Shared Devices
3. Virtual Devices
Device Management 4/23/2019 6
These are devices that are assigned to one process at a time,
and the process only releases the device once it is completed.
This makes sense for devices like plotters, and tape drives.
The problem with this is that only one user is using it at a
time, and it might be inefficient if the device isn’t being used
100% of the time that it is being locked by the user.
Device Management 4/23/2019 7
These are devices that can be shared between several
processes.
Considering an example like a hard disk, it is shared, but
interleaving between different processes’ requests.
All conflicts for device need to be resolved but pre-determined
policies to decide which request is handled first.
Device Management 4/23/2019 8
These devices are a combination of
dedicated and shared devices.
So a printer is a dedicated device, but
using the spooling (queues) means it
can be shared.
A print job isn’t sent straight to the
printer, instead it goes to the disk
(spool) until it is fully prepared with
all the necessary printer sequences
and formatting, then it goes to the
printer, ensuring that the printers (and
all I/O devices) are used efficiently.
Allowed jobs to be read ahead onto
disk
Device Management 4/23/2019 9
Spool (Simultaneous Peripheral Operation On-Line)
A spool is a buffer that holds output for a device, such as a
printer, that cannot accept interleaved data streams.
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.
Device Management 4/23/2019 10
Differences between I/O devices: data rate, application,
complexity of control, unit of transfer, data representation,
error conditions.
Differences
◦ Data transfer rates
Range from 0.01 kbytes/sec (keyboard) till 30.000
kbytes/second (graphical screen)
Disks typically have 500 kbytes/sec (optical) till 2000
kbytes/sec (magnetic)
◦ Application
Disk for files or for virtual memory
Influences disk scheduling and caching strategy
◦ Complexity
OS is isolated from most of the complexity by an I/O
module (controller)
Device Management 4/23/2019 11
◦ Unit of transfer
Blocks of characters versus streams of characters
◦ Representation of data
Coding conventions,…
◦ Error states
Kind of errors, reporting modes,…
Need a uniform approach to I/O as seen from the user and
from the operating system point of view
Device Management 4/23/2019 12
The I/O function can be approached in three ways:
Programmed I/O: continuous attention of the processor is
required
Interrupt driven I/O: processor launches I/O and can
continue until interrupted
Direct memory access: The DMA module governs the
exchange of data between the I/O unit and the main
memory
Device Management 4/23/2019 13
Human readable
– For communication between humans and computers
e.g., printers, keyboards
Machine readable
– For the use of electronic equipment
e.g., disks, sensors
Communication
– For communication with remote devices
e.g., modems
Device Management 4/23/2019 14
Block devices
– Store information in blocks of fixed size; one block at a time
transferred
– Possible to reference data by its block number
– Examples: disks, USB keys
Character devices (or stream devices)
– Transfers data in and out as a stream of bytes; no block
structure
– Examples: most devices that are not secondary storage
Device Management 4/23/2019 15
Slow devices like keyboards will generate an interrupt to the
main CPU after each byte is transferred.
If a fast device such as a disk generated an interrupt for each
byte, the operating system would spend most of its time
handling these interrupts.
So a typical computer uses direct memory access (DMA)
hardware to reduce this overhead.
Direct Memory Access (DMA) means CPU grants I/O module
authority to read from or write to memory without
involvement.
DMA module itself controls exchange of data between main
memory and the I/O device.
CPU is only involved at the beginning and end of the transfer
and interrupted only after entire block has been transferred.
Device Management 4/23/2019 16
Direct Memory Access needs a special hardware called DMA
controller (DMAC) that manages the data transfers and
arbitrates access to the system bus.
The controllers are programmed with source and destination
pointers (where to read/write the data), counters to track the
number of transferred bytes, and settings, which includes I/O
and memory types, interrupts and states for the CPU cycles.
Device Management 4/23/2019 17
Device Management 4/23/2019 18
1. Processor controls device directly
2. A controller or I/O module is used separating the processor
from the details of the I/O device
3. As in 2 but using interrupts, the burden of supervising the
device continuously disappears
4. I/O module gains access to main memory through DMA
moving data in and out memory without processor attention
5. I/O module becomes a processor - I/O specific instruction
set – to be programmed by the processor in main memory
Device Management 4/23/2019 19
Device Management 4/23/2019 20
Buffering happens at provider when:
The data source has:
1. Bandwidth problems
2. Hardware problems
3. Software problems
Device Management 4/23/2019 21
Buffering means working with large chunks of data in main
memory so the number of accesses to secondary storage is
reduced.
These are beyond the control of application programs and are
manipulated by the O.S.
Note that the application program may implement its own
“buffer” – i.e. a place in memory (variable, object) that
accumulates large chunks of data to be later written to disk as
a chunk.
Device Management 4/23/2019 22
Double Buffering: Two buffers can be used to allow
processing and I/O to overlap.
– Suppose that a program is only writing to a disk.
– CPU wants to fill a buffer at the same time that I/O is being
performed.
– If two buffers are used and I/O-CPU overlapping is
permitted, CPU can be filling one buffer while the other
buffer is being transmitted to disk.
– When both tasks are finished, the roles of the buffers can
be exchanged.
The actual management is done by the O.S.
Device Management 4/23/2019 23
Device Management 4/23/2019 24
Multiple Buffering: instead of two buffers any number of
buffers can be used to allow processing and I/O to overlap.
Buffer pooling:
– There is a pool of buffers.
– When a request for a sector is received, O.S. first looks to see
that sector is in some buffer.
– If not there, it brings the sector to some free buffer. If no free
buffer exists, it must choose an occupied buffer.
Device Management 4/23/2019 25
Move mode (using both system buffer & program buffer)
– moving data from one place in RAM to another before they
can be accessed
– sometimes, unnecessary data moves
Locate mode (using system buffer only or program buffer
only)
– perform I/O directly between secondary storage and
program buffer (program’s data area)
– system buffers handle all I/Os, but program uses locations
through pointer variable
Device Management 4/23/2019 26
Device Management 4/23/2019 27
Recovery in computer systems refers to restoring a system to
its normal operational state.
Recovery may be as simple as restarting a failed computer or
restarting failed processes. However, it will be clear that
recovery is generally a very complicated process.
In general, resources are allocated to executing processes in a
computer.
For example, a process has memory allocated to it and a
process may have locked shared resources, such as files and
memory. Under such circumstances, if a process fails, it is
vital that the resources allocated to the failed process are
undone.
Device Management 4/23/2019 28
A system consists of a set of hardware and software
components and is designed to provide a specified service.
The components of a system may themselves be systems
together with interrelationships.
Failure of a system occurs when the system does not perform
its services in the manner specified.
An invalid state of the system is a state which could lead to a
system failure by a sequence of valid state transitions.
A fault is an irregular physical condition.
Device Management 4/23/2019 29
The causes of a fault include
design errors (such as error in system specification or
implementation),
manufacturing problems,
damage fatigue or other deterioration, and
external disturbances (such as harsh environmental
conditions, electromagnetic interference, unanticipated inputs
or system misuse).
An error is that part of the system state which differs from its
intended value.
Device Management 4/23/2019 30
Fault
Manufacturing Design External Fatigue &
Problems Errors disturbances Deterioration
Erroneous Erro
system state r
Process / System
Failure
Device Management 4/23/2019 31
Failures in a computer system can be classified as follows:
Process Failure
System Failure
Secondary Storage Failure
Communication Medium Failure
Device Management 4/23/2019 32
In a Process Failure, the computation results in an incorrect
outcome,
The process causes the system state to move away from
specifications, the process may fail to progress.
Device Management 4/23/2019 33
System Failure: A system failure occurs when the processor
fails to execute.
It is caused by software errors and hardware problems (such as
CPU failure, main memory failure, bus failure, power failure,
etc.)
In the case a system failure, the system is stopped and
restarted in a correct state.
Device Management 4/23/2019 34
A secondary storage failure is said to have occurred when
the stored data (either some parts of it or in its entirety) cannot
be accessed.
This failure is usually caused by
◦ parity error,
◦ head crash, or
◦ dust particles settled on the medium.
In the case of a secondary storage failure, its contents are
corrupted and must be reconstructed from an archive version,
plus a log of activities since the archive was taken.
Device Management 4/23/2019 35
A communication medium failure occurs when a site cannot
communicate with another operational site in the network.
It is usually caused by the failure of the switching nodes
and/or the links of the communicating system.
The failure of a switching node includes system failure and
secondary storage failure, and a link failure includes physical
break and noise in the communication channels.
Note that a communication medium failure (although depends
upon the topology and connectivity) may not cause a total shut
down of communication facilities.
Device Management 4/23/2019 36
Recall that an error is that part of the state that differs from its
intended value and can lead to a system failure, and
Failure recovery is a process that involves restoring an
improper state to an error-free state.
There are two approaches for restoring an improper state to an
error-free state.
1. If the nature of errors and damages caused by faults can be
completely and accurately assessed, then its is possible to
remove those errors in the process’s (system’s) state and
enable the process (system) to move forward. This technique
is known as forward-error recovery.
Device Management 4/23/2019 37
2. If it is not possible to predict the nature of faults and to
remove all the errors in the process’s (system’s) state, then
the process’s (system’s) state can be restored to a previous
error-free state of the process (system). This technique is
known as backward-error recovery.
Note that backward-error recovery is simpler than forward-
error recovery as it is independent of the fault and the error
caused by the fault.
Thus, a system can recover from an arbitrary fault by
restoring to a previous state.
This generality enables backward-error recovery to be
provided as a general recovery mechanism to any type of
process.
Device Management 4/23/2019 38
The major problems associated with the backward-error recovery
approach are:-
Performance penalty: The overhead to restore a process
(system) state to a previous state can be quite high.
There is no guarantee that faults will not occur again when
processing begins from a previous state.
Some component of the system state may be unrecoverable.
For example, cash distributed at an automatic teller machine
cannot be recovered.
Device Management 4/23/2019 39
The forward-error recovery technique, on the other hand,
incurs less overhead because only those parts of the state that
deviate from the intended value need to be corrected.
However, this technique can be used only where the damages
due to faults can be correctly assessed, and hence it is not a
concept as general as the backward-error recovery and cannot
be provided as a general mechanism for error recovery.
Device Management 4/23/2019 40
Backward-error Recovery Basic Approaches
In backward-error recovery, a process is restored to a previous
state in the hope that the previous state is free of errors.
The points in the execution of a process to which the process
can later be restored are known as recovery points.
Recovery done at the process level is simply a subset of the
actions necessary to recover the entire system.
Device Management 4/23/2019 41