Chapter 4.
Device and Information Management
Device Management in Operating System
Device management in an operating system means controlling the Input/Output devices like disk,
microphone, keyboard, printer, magnetic tape, USB ports, camcorder, scanner, other accessories, and
supporting units like supporting units control channels. A process may require various resources,
including main memory, file access, and access to disk drives, and others. If resources are available, they
could be allocated, and control returned to the CPU. Otherwise, the procedure would have to be
postponed until adequate resources become available. The system has multiple devices, and in order to
handle these physical or virtual devices, the operating system requires a separate program known as an
ad device controller. It also determines whether the requested device is available.
The fundamentals of I/O devices may be divided into three categories:
Boot Device
Character Device
Network Device
Boot Device
It stores data in fixed-size blocks, each with its unique address. For example- Disks.
Character Device
It transmits or accepts a stream of characters, none of which can be addressed individually. For instance,
keyboards, printers, etc.
Network Device
It is used for transmitting the data packets.
Functions of the device management in the operating system
The operating system (OS) handles communication with the devices via their drivers. The OS component
gives a uniform interface for accessing devices with various physical features. There are various
functions of device management in the operating system. Some of them are as follows:
It keeps track of data, status, location, uses, etc. The file system is a term used to define a group
of facilities.
It enforces the pre-determined policies and decides which process receives the device when and
for how long.
It improves the performance of specific devices.
It monitors the status of every device, including printers, storage drivers, and other devices.
It allocates and effectively deallocates the device. De-allocating differentiates the devices at two
levels: first, when an I/O command is issued and temporarily freed. Second, when the job is
completed, and the device is permanently release
Techniques for Device Management:
The major techniques are used for managing and allocating the devices : 1) Dedicated , 2) shared and 3)
Virtual.
1. Dedicated Device
In device management, some devices are allocated or assigned to only one task at a time until that job
releases them. Devices such as plotters, printers, tape drivers, and other similar devices necessitate such
an allocation mechanism because it will be inconvenient if multiple people share them simultaneously.
The disadvantage of such devices is the inefficiency caused by allocating the device to a single user for
the whole duration of task execution, even if the device is not used 100% of the time.
2. Shared Devices
These devices could be assigned to a variety of processes. By interleaving their requests, disk-DASD
could be shared by multiple processes simultaneously. The Device Manager carefully controls the
interleaving, and pre-determined policies must resolve all difficulties.
3. Virtual Devices
Virtual devices are a hybrid of the two devices, and they are dedicated devices that have been
transformed into shared devices. For example, a printer can be transformed into a shareable device by
using a spooling program that redirects all print requests to a disk. A print job is not sent directly to the
printer; however, it is routed to the disk until it is fully prepared with all of the required sequences and
formatting, at which point it is transmitted to the printers. The approach can transform a single printer
into numerous virtual printers, improving performance and ease of use.
Features of Device Management
Various features of the device management are as follows:
The OS interacts with the device controllers via the device drivers while allocating the device to
the multiple processes executing on the system.
Device drivers can also be thought of as system software programs that bridge processes and
device controllers.
The device management function's other key job is to implement the API.
Device drivers are software programs that allow an operating system to control the operation of
numerous devices effectively.
The device controller used in device management operations mainly contains three registers:
command, status, and data.
Device characteristics- Hardware Consideration:
Devices can be categorizes into two groups.
1. Input/Output Device.
2. Storage devices.
1. Input/Output Devices:
An input devices takes data from the outside world.
An output device which produce data to the outside world.
Example : Card reader (Input device), Printer (output Device)
2. Storage Device:
It is a mechanism by which the computer may store the information in such a way that information may
be retrieve at later time.
There are following three types of storage devices.
1. Serial Access Devices.
2. Completely Direct Access.
3. Direct Access Storage device (DASD).
1. Serial Access Devices:
It can be characterized as one that dependence on physical sequential positioning and accessing
information.
Example, Magnetic tape unit where information is stored as a group of byte called records of any
length.
Each record can be identify by it physical position on the tap
Example, the first record is one second record is second and So on.
2. Completely direct access devices:
A completely direct access devices are one in which the access time is constant.
It requires less time and less cost.
Example, Magnetic code memory, semiconductor memory And read only wired memory
In figure the 16 circles represent magnetic cores. All cores are connected by wires, each core having two
selection wires through it. When hardware receives a read request for some address, the address is
decomposed into x and y position. The hardware then selects the appropriate core.
3. Direct Access storage device (DASD):
A direct access device is one that is characterized by small variances in the access time. These
have been called direct access storage devices.
Example :Magnetic drum and disk.
In a magnetic drum can be viewed as several adjacent strips of magnetic tape wrapped around
a drum so that the ends of each tape strip join. Each tape strip ,called track, and its separate
read/write head. The drum continuously revolves at high speed so that record repeatedly pass
under the read/write head. (e.g record1,record2.., then record1 again,record2…etc). Each
individual record is identified by a track number and then a record number.
Fixed head drum
Example: record (2,1) is X’C4C9E2D2’ and
record (5,1) is X’D1D6C5D5’.
Each record is identified by track no and record number.
I/O scheduling in Operating Systems:
How are I/O operations performed?
Operating stem has a certain portion of code that is dedicated to managing
Input/Output in order to improve the reliability and the performance of the system. A
computer system contains CPUs and more than one device controllers connected to a
common bus channel, generally referred to as the device driver. These device drivers
provide an interface to I/O devices for communicating with the system hardware
promoting ease of communication providing access to shared memory.
I/O Requests in operating systems :
I/O Requests are managed by Device Drivers in collaboration with some system
programs inside the I/O device. The requests are served by OS using three simple
segments :
I/O Traffic Controller: Keeps track of the status of all devices, control units, and
communication channels. The traffic controller maintains all status information. The traffic
controller maintains a database reflecting status and connections. This can be accomplished by
means of Unit Control Block (UCB), Control Unit Control Block (CUCB), and Channel Control
Block (CCB). In OS the primary role of the I/O Traffic Controller is to co-ordinate and control the
actions of the hardware and the software in a CPU including the input, output and the storage
devices. The CPU processes the data via traffic controller and allows the simultaneous working
and processing of the I/O devices. It is also reffered as I/O interface, I/O controller or PIOC
(peripheral I/O controller).
I/O Traffic Controller has 3 main tasks :
The primary task is to check if there’s at least one path available.
If there exists more than one path, it must decide which one to select.
If all paths are occupied, its task is to analyze which path will be available at the
earliest.
Unit Control Block (UCB) Channel Control Block
(CCB)
Device Unit Channel identification
identification
Status of device Status of channel
List of control Units List of control Units
connected to the device connected to this channel
List of processes waiting List of processes waiting for
for this device this channel
Control Unit Control Block (CUCB)
Control Unit identification
Status of the control unit
List of devices connected to this control unit
List of channels connected to the control unit
List of processes waiting for this control unit
I/O scheduler: Executes the policies used by OS to allocate and access the device,
control units, and communication channels.
I/O Scheduling in operating systems:
Scheduling is used for efficient usage of computer resources avoiding deadlock and
serving all processes waiting in the queue.
I/O Scheduler functions similar to Process scheduler, it allocates the devices, control
units, and communication channels. However, under heavy load of I/O requests, Scheduler
must decide what request should be served first and for that we multiple queues to be
managed by OS.
The major difference between Process scheduler and I/O scheduler is that I/O requests
are not preempted: Once the channel program has started, it’s allowed to continue to
completion. Although it is feasible because programs are relatively short (50 to 100 ms). Some
modern OS allows I/O Scheduler to serve and higher priority requests. In simpler words, If an
I/O request has higher priority then they are served before other I/O requests with lower
priority. I/O scheduler works in coordination with the I/O traffic controller to keep track of
which path is being served for the current I/O request.
Once the I/O scheduler has determined the relative orderings of the I/O requests, the
I/O traffic controller must determine which, if any, of them can be satisfied. The I/O device
handlers then provide another level of device-independent I/O scheduling and optimization.
I/O device handler: Serves the device interrupts and heads the transfer of data. In
addition to setting up the channel command words, handling error conditions, and processing
I/O interrupts, the I/O device handlers provide detailed scheduling algorithms that are
dependent upon the peculiarities of the device type.
I/O Device Handler manages the I/O interrupts (if any) and scheduling algorithms. Few
I/O handling algorithms are :
FCFS [First come first server].
SSTF [Shortest seek time first].
SCAN
Look
N-Step Scan
C-SCAN
C-LOOK
Every scheduling algorithm aims to minimize arm movement, mean response time,
variance in response time. An overview of all I/O scheduling algorithms are described below :
First Come First Serve [FCFS]:
It is one of the simplest device-scheduling algorithms since it is easy to program and
essentially fair to users (I/O devices). The only barrier could be the high seek time, so any other
algorithm that can surpass the minimum seek time is suitable for scheduling.
Shortest Seek Time First [SSTF]:
It uses the same ideology as the Shortest Job First in process scheduling, where shortest
processes are served first and longer processes have to wait for their turn. Comparing the SJF
concept in I/O scheduling, the request with track closest to one being served (The one with the
shortest distance to travel on disk) is next to be satisfied. The main advantage over FCFS is that
it minimizes overall seek time. It favors easy-to-reach requests and postpone traveling to those
that are out of the way.
SCAN Algorithm:
SCAn uses a status flag which tells the direction of the arm, it tells whether the arm is
moving towards the center of the disk or to the other side. This algorithm moves arm from the
end of the disk to the center track servicing every request in its way. When it reaches innermost
track, it reverses the direction and moves towards outer tracks on the disk, again servicing
every request in its path.
LOOK [Elevator Algorithm]:
It’s a variation of SCAN algorithm, here arm doesn’t necessarily go all the way to either
side on disk unless there are requests pending. It looks ahead for a request before servicing it. A
big question arises is “Why should we use LOOK over SCAN?”. The major advantage of LOOK
over SCAN is that it discards the indefinite delay of I/O requests.
Other variations of SCAN:
N-Step Scan: It holds all the pending requests until the arm starts its way back. New
requests are grouped for the next cycle of rotation.
C-SCAN [Circular SCAN]: It provides a uniform wait time as the arm serves requests on
its way during the inward cycle. To know more, refer Difference between SCAN and C-SCAN.
C-LOOK [Optimized version of C-SCAN]: Arm doesn’t necessarily return to the lowest-
numbered track, it returns from the lowest request to be served. It optimized the C-SCAN as the
arm doesn’t move to the end of the disk if not required. To know more, refer to the Difference
between C-LOOK and C-SCAN.