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

Device Management in OS

Uploaded by

Diya Pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views

Device Management in OS

Uploaded by

Diya Pathak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

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:

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.

Features of Device Management


Here, you will learn the features of device management in the operating system. Various features
of the device management are as follows:

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.

Disk Scheduling Algorithms in OS (Operating System)


As we know, a process needs two type of time, CPU time and IO time. For I/O, it requests the
Operating system to access the disk.

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.

Let's discuss some important terms related to disk scheduling.


Seek Time
Seek time is the time taken in locating the disk arm to a specified track where the read/write
request will be satisfied.

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.

Disk Access Time


Disk access time is given as,

Disk Access Time = Rotational Latency + Seek Time + Transfer Time

Disk Response Time


It is the average of time spent by each request waiting for the IO operation.

Purpose of Disk Scheduling


The main purpose of disk scheduling algorithm is to select a disk request from the queue of IO
requests and decide the schedule when this request will be processed.

Goal of Disk Scheduling Algorithm

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.

o FCFS scheduling algorithm


o SSTF (shortest seek time first) algorithm
o SCAN scheduling
o C-SCAN scheduling
o LOOK Scheduling
o C-LOOK scheduling

FCFS Scheduling Algorithm


It is the simplest Disk Scheduling algorithm. It services the IO requests in the order in which
they arrive. There is no starvation in this algorithm, every request is serviced.

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

Number of cylinders moved by the head

= (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

Average seek length= 403/11 = 36.63


SSTF Scheduling Algorithm
Shortest seek time first (SSTF) algorithm selects the disk I/O request which requires the least
disk arm movement from its current position regardless of the direction. It reduces the total seek
time as compared to FCFS.

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

45, 21, 67, 90, 4, 89, 52, 61, 87, 25

Head pointer starting at 50. Find the number of head movements in cylinders using SSTF
scheduling.

Solution:

Number of cylinders = 5 + 7 + 9 + 6 + 20 + 2 + 1 + 65 + 4 + 17 = 136


SCAN and C-SCAN algorithm
Scan Algorithm
It is also called as Elevator Algorithm. In this algorithm, the disk arm moves into a particular
direction till the end, satisfying all the requests coming in its path,and then it turns backand
moves in the reverse direction satisfying requests coming in its path.

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

98, 137, 122, 183, 14, 133, 65, 78

Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using SCAN scheduling.

Number of Cylinders = 40 + 14 + 65 + 13 + 20 + 24 + 11 + 4 + 46 = 237


C-SCAN algorithm
In C-SCAN algorithm, the arm of the disk moves in a particular direction servicing requests until
it reaches the last cylinder, then it jumps to the last cylinder of the opposite direction without
servicing any request then it turns back and start moving in that direction servicing the remaining
requests.

Example
Consider the following disk request sequence for a disk with 100 tracks

98, 137, 122, 183, 14, 133, 65, 78

Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using C-SCAN scheduling.

No. of cylinders crossed = 40 + 14 + 183 + 46 + 4 + 11 + 24 + 20 + 13 = 355


Look Scheduling
It is like SCAN scheduling Algorithm to some extant except the difference that, in this
scheduling algorithm, the arm of the disk stops moving inwards (or outwards) when no more
request in that direction exists. This algorithm tries to overcome the overhead of SCAN
algorithm which forces disk arm to move in one direction till the end regardless of knowing if
any request exists in the direction or not.

Example
Consider the following disk request sequence for a disk with 100 tracks

98, 137, 122, 183, 14, 133, 65, 78

Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using LOOK scheduling.

Number of cylinders crossed = 40 + 51 + 13 + +20 + 24 + 11 + 4 + 46 = 209


C Look Scheduling
C Look Algorithm is similar to C-SCAN algorithm to some extent. In this algorithm, the arm of
the disk moves outwards servicing requests until it reaches the highest request cylinder, then it
jumps to the lowest request cylinder without servicing any request then it again start moving
outwards servicing the remaining requests.

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

98, 137, 122, 183, 14, 133, 65, 78

Head pointer starting at 54 and moving in left direction. Find the number of head movements in
cylinders using C LOOK scheduling.

Number of cylinders crossed = 11 + 13 + 20 + 24 + 11 + 4 + 46 + 169 = 298


Numerical on SSTF and SCAN
Question:

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

Using SSTF Algorithm


Number of track are 100.

Initial Position of R/W head is 50.

The requests are: 45, 20, 90, 10, 50, 60, 80 and 70

Number of crossed cylinders = 5 + 15 + 10 + 10 + 10 + 70 + 10 = 130


Using SCAN Algorithm

Number of cylinders crosses = 0 + 10 + 10 + 10 + 10 + 10 + 55 + 25 + 10 = 140

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 :

You might also like