Topic: TYPES OF SOFTWARE
Subject:- Operating System
Subject Code:- CSL-301
Assistant Professor: Manish Kumar Jain
CSA Department ,ITM University Gwalior
I/O management in Operating System
Assistant Prof. Manish Kumar Jain
ITM University Gwalior
Computer Science and Application
How are I/O operations performed?
• operating System 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
controller 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
and providing access to shared memory.
How are I/O operations performed?
How are I/O operations
performed?
• 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 :
1.I/O Traffic Controller: Keeps track of the status of all devices, control units,
and communication channels.
2.I/O scheduler: Executes the policies used by OS to allocate and access the
device, control units, and communication channels.
3.I/O device handler: Serves the device interrupts and heads the transfer of
data.
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 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.
• Scheduling in computing is the process of allocating resources to carry out tasks. Processors, network
connections, or expansion cards are examples of the resources. The tasks could be processes,
threads, or data flows.
• A process referred to as a scheduler is responsible for scheduling. Schedulers are frequently made to
keep all computer resources active (as in load balancing), efficiently divide up system resources
among multiple users, or reach a desired level of service.
• I/O Scheduler functions similarly to Process scheduler, it allocates the devices, control units, and
communication channels. However, under a 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 a Process scheduler< and an 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 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. The 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. I/O Device Handler manages the I/O interrupts (if any) and scheduling algorithms.
Disk Scheduling Algorithms
• Disk scheduling is a technique operating systems use to manage
the order in which disk I/O (input/output) requests are processed.
Disk scheduling is also known as I/O Scheduling. The main goals of
disk scheduling are to optimize the performance of disk operations,
reduce the time it takes to access data and improve overall system
efficiency.
• In this article, we will explore the different types of disk scheduling
algorithms and their functions. By understanding and implementing
these algorithms, we can optimize system performance and ensure
faster data retrieval.
What are Disk Scheduling Algorithms?
• Disk scheduling algorithms are crucial in managing how data
is read from and written to a computer’s hard disk. These
algorithms help determine the order in which disk read and
write requests are processed, significantly impacting the
speed and efficiency of data access. Common disk scheduling
methods include First-Come, First-Served (FCFS), Shortest
Seek Time First (SSTF), SCAN, C-SCAN, LOOK, and C-LOOK. By
understanding and implementing these algorithms, we can
optimize system performance and ensure faster data retrieval.
Importance of Disk Scheduling in Operating
System
• Multiple I/O requests may arrive by different processes and only
one I/O request can be served at a time by the disk controller.
Thus other I/O requests need to wait in the waiting queue and
need to be scheduled.
• Two or more requests may be far from each other so this can
result in greater disk arm movement.
• Hard drives are one of the slowest parts of the computer system
and thus need to be accessed in an efficient manner.
Key Terms Associated with Disk Scheduling
• Seek Time: Seek time is the time taken to locate the disk arm to a
specified track where the data is to be read or written. So the disk
scheduling algorithm that gives a minimum average seek time is better.
• Rotational Latency: Rotational Latency is the time taken by the desired
sector of the disk to rotate into a position so that it can access the
read/write heads. So the disk scheduling algorithm that gives minimum
rotational latency is better.
• Transfer Time: Transfer time is the time to transfer the data. It depends
on the rotating speed of the disk and the number of bytes to be
transferred.
Disk Access Time:
• Disk Access Time = Seek Time + Rotational Latency +
Transfer Time
• Total Seek Time = Total head Movement * Seek Time
Disk Response Time
• Disk Response Time: Response Time is the average time
spent by a request waiting to perform its I/O operation. The
average Response time is the response time of all
requests. Variance Response Time is the measure of how
individual requests are serviced with respect to average
response time. So the disk scheduling algorithm that gives
minimum variance response time is better.
1. FCFS (First Come First Serve)
• FCFS is the simplest of all Disk Scheduling Algorithms. In
FCFS, the requests are addressed in the order they arrive
in the disk queue. Let us understand this with the help of
an example.
• Advantages of FCFS
• Here are some of the advantages of First Come First Serve.
• Every request gets a fair chance
• No indefinite postponement
• Disadvantages of FCFS
• Here are some of the disadvantages of First Come First
Serve.
• Does not try to optimize seek time
• May not provide the best possible service
2. SSTF (Shortest Seek Time First)
• In SSTF (Shortest Seek Time First), requests having the shortest
seek time are executed first. So, the seek time of every request is
calculated in advance in the queue and then they are scheduled
according to their calculated seek time. As a result, the request
near the disk arm will get executed first. SSTF is certainly an
improvement over FCFS as it decreases the average response time
and increases the throughput of the system. Let us understand this
with the help of an example.
• Advantages of Shortest Seek Time First
• Here are some of the advantages of Shortest Seek Time First.
• The average Response Time decreases
• Throughput increases
• Disadvantages of Shortest Seek Time First
• Here are some of the disadvantages of Shortest Seek Time First.
• Overhead to calculate seek time in advance
• Can cause Starvation for a request if it has a higher seek time as
compared to incoming requests
• The high variance of response time as SSTF favors only some
requests
3. SCAN
• In the SCAN algorithm the disk arm moves in a particular
direction and services the requests coming in its path and
after reaching the end of the disk, it reverses its direction
and again services the request arriving in its path. So, this
algorithm works as an elevator and is hence also known as
an elevator algorithm. As a result, the requests at the
midrange are serviced more and those arriving behind the
disk arm will have to wait.
• Advantages of SCAN Algorithm
• Here are some of the advantages of the SCAN Algorithm.
• High throughput
• Low variance of response time
• Average response time
• Disadvantages of SCAN Algorithm
• Here are some of the disadvantages of the SCAN Algorithm.
• Long waiting time for requests for locations just visited by disk arm
4. C-SCAN
• In the SCAN algorithm, the disk arm again scans the path that has
been scanned, after reversing its direction. So, it may be possible
that too many requests are waiting at the other end or there may
be zero or few requests pending at the scanned area.
• These situations are avoided in the CSCAN algorithm in which the
disk arm instead of reversing its direction goes to the other end of
the disk and starts servicing the requests from there. So, the disk
arm moves in a circular fashion and this algorithm is also similar to
the SCAN algorithm hence it is known as C-SCAN (Circular SCAN).
• Suppose the requests to be addressed are-
82,170,43,140,24,16,190. And the Read/Write arm is at 50,
and it is also given that the disk arm should
move “towards the larger value”.
• So, the total overhead movement (total distance covered
by the disk arm) is calculated as:
• Advantages of C-SCAN Algorithm
• Here are some of the advantages of C-SCAN.
• Provides more uniform wait time compared to SCAN.
5. LOOK
• LOOK Algorithm is similar to the SCAN disk scheduling
algorithm except for the difference that the disk arm in
spite of going to the end of the disk goes only to the last
request to be serviced in front of the head and then
reverses its direction from there only. Thus it prevents the
extra delay which occurred due to unnecessary traversal to
the end of the disk.
6. C-LOOK
• As LOOK is similar to the SCAN algorithm, in a similar way, C-LOOK is
similar to the CSCAN disk scheduling algorithm. In CLOOK, the disk arm
in spite of going to the end goes only to the last request to be serviced
in front of the head and then from there goes to the other end’s last
request. Thus, it also prevents the extra delay which occurred due to
unnecessary traversal to the end of the disk.
• Example:
1.Suppose the requests to be addressed are-82,170,43,140,24,16,190.
And the Read/Write arm is at 50, and it is also given that the disk arm
should move “towards the larger value”