Device Management in OS
Device Management in OS
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.
1. Boot Device
2. Character Device
3. 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:
1. It keeps track of data, status, location, uses, etc. The file system is a term used to define a
group of facilities.
2. It enforces the pre-determined policies and decides which process receives the device
when and for how long.
3. It improves the performance of specific devices.
4. It monitors the status of every device, including printers, storage drivers, and other
devices.
5. 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
Types of devices
There are three types of Operating system peripheral devices: dedicated, shared, and virtual.
These are as follows:
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.
1. The OS interacts with the device controllers via the device drivers while allocating the
device to the multiple processes executing on the system.
2. Device drivers can also be thought of as system software programs that bridge processes
and device controllers.
3. The device management function's other key job is to implement the API.
4. Device drivers are software programs that allow an operating system to control the
operation of numerous devices effectively.
5. The device controller used in device management operations mainly contains three
registers: command, status, and data.
However, the operating system must be fare enough to satisfy each request and at the same time,
operating system must maintain the efficiency and speed of process execution.
The technique that operating system uses to determine the request which is to be satisfied next is
called disk scheduling.
Rotational Latency
It is the time taken by the desired sector to rotate itself to the position from where it can access
the R/W heads.
Transfer Time
It is the time taken to transfer the data.
o Fairness
o High throughout
o Minimal traveling head time
Disk Scheduling Algorithms
The list of various disks scheduling algorithm is given below. Each algorithm is carrying some
advantages and disadvantages. The limitation of each algorithm leads to the evolution of a new
algorithm.
Disadvantages
o The scheme does not optimize the seek time.
o The request may come from different processes therefore there is the possibility of
inappropriate movement of the head.
Example
Consider the following disk request sequence for a disk with 100 tracks 45, 21, 67, 90, 4, 50, 89,
52, 61, 87, 25
Head pointer starting at 50 and moving in left direction. Find the number of head movements in
cylinders and average seek length using FCFS scheduling.
Solution
= (50-45)+(45-21)+(67-21)+(90-67)+(90-4)+(50-4)+(89-50)+(89-52)+(61-52)+(87-61)+(87-25)
= 5 + 24 + 46 + 23 + 86 + 46 + 39 +37+ 9 + 26 + 62
= 403
It allows the head to move to the closest track in the service queue.
Disadvantages
o It may cause starvation for some requests.
o Switching direction on the frequent basis slows the working of algorithm.
o It is not the most optimal algorithm.
Example
Consider the following disk request sequence for a disk with 100 tracks
Head pointer starting at 50. Find the number of head movements in cylinders using SSTF
scheduling.
Solution:
It works in the way an elevator works, elevator moves in a direction completely till the last floor
of that direction and then turns back.
Example
Consider the following disk request sequence for a disk with 100 tracks
Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using SCAN scheduling.
Example
Consider the following disk request sequence for a disk with 100 tracks
Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using C-SCAN scheduling.
Example
Consider the following disk request sequence for a disk with 100 tracks
Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using LOOK scheduling.
It is different from C SCAN algorithm in the sense that, C SCAN force the disk arm to move till
the last cylinder regardless of knowing whether any request is to be serviced on that cylinder or
not.
Example
Consider the following disk request sequence for a disk with 100 tracks
Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using C LOOK scheduling.
Suppose the following disk request sequence (track numbers) for a disk with 100 tracks is given:
45, 20, 90, 10, 50, 60, 80 and 70. Assume that the initial position of the R/W head is on track 50.
The additional distance that will be traversed by the R/W head when the Shortest Seek Time
First (SSTF) algorithm is used compared to the SCAN (Elevator) algorithm (assuming that
SCAN algorithm moves towards 100 when it starts execution) is _________ tracks
(A) 5
(B) 9
(C) 10
(D) 11
The requests are: 45, 20, 90, 10, 50, 60, 80 and 70
Therefore the answer is (C). The SCAN algorithm travels for 10 additional tracks.
Numerical on Disk Scheduling Algorithms
Q. Consider a disk with 200 tracks and the queue has random requests
from different processes in the order:
55, 58, 39, 18, 90, 160, 150, 38, 184
Initially arm is at 100. Find the Average Seek length using FIFO, SSTF, SCAN and C-SCAN
C
algorithm.
Solution :