0% found this document useful (0 votes)
39 views32 pages

Io Management and Disk Scheduling

Operating system slides

Uploaded by

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

Io Management and Disk Scheduling

Operating system slides

Uploaded by

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

I/O MANAGEMENT

AND DISK SCHEDULING


I/O DEVICES
• Categories:
•> Human readable: Suitable for communicating with the computer
user. Examples :include printers and terminals, the latter consisting
of video display, keyboard, and perhaps other devices such as a
mouse.
•> Machine readable: Suitable for communicating with electronic
equipment. Examples are disk drives, USB keys, sensors,
controllers, and actuators.
•> Communication: Suitable for communicating with remote
devices. Examples are digital line drivers and modems.

• There are great differences across classes and even substantial differences
within each class. Among the key differences are the following:
• Data rate
• Application
• Complexity of control
• Complexity of control
• Data representation
• Error conditions
ORGANIZATION OF THE I/O
FUNCTION
• Programmed I/O: The processor issues an I/O command, on behalf of a
process, to an I/O module; that process then busy waits for
the operation to be completed before proceeding.

• Interrupt-driven I/O: The processor issues an I/O command on behalf of a


process. There are then two possibilities. If the I/O
instruction from the process is nonblocking, then the
processor continues to execute instructions from the
process that issued the I/O command. If the I/O instruction
is blocking, then the next instruction that the processor
executes is from the OS, which will put the current process
in a blocked state and schedule another process.

• Direct memory access (DMA): A DMA module controls the exchange of data
between main memory and an I/O module. The
processor sends a request for the transfer of a
block of data to the DMA module and is
interrupted only after the entire block has been
transferred.
The Evolution of the I/O
Function
• The evolutionary steps can be summarized as follows:
The processor directly controls a peripheral device
A controller or I/O module is added.The processor uses programmed
I/O without interrupts.
The same configuration as step 2 is used, but now interrupts are
employed.The processor need not spend time waiting for an I/O
operation to be performed, thus increasing efficiency.
The I/O module is given direct control of memory via DMA.
The I/O module is enhanced to become a separate processor, with a
specialized instruction set tailored for I/O.The central processing unit
(CPU) directs the I/O processor to execute an I/O program in main
memory
The I/O module has a local memory of its own and is, in fact, a
computer in its own right
Direct Memory Access
•> The DMA unit is capable of mimicking
the processor and, indeed, of taking over
control of the system bus just like a
processor. It needs to do this to transfer
data to and from memory over the system
bus.

•> The DMA technique works as


follows.When the processor wishes to read
or write a block of data, it issues a
command to the DMA module by sending
to the DMA module the information
OPERATING SYSTEM
DESIGN ISSUES
Design Objectives

• Two objectives are paramount in designing the I/O facility: efficiency and generality.
Efficiency is important because I/O operations often form a bottleneck in a
computing system.

• Swapping is used to bring in additional ready processes to keep the processor busy,
but this in itself is an I/O operation.Thus, a major effort in I/O design has been
schemes for improving the efficiency of the I/O.The area that has received the most
attention, because of its importance, is disk I/O, and much of this chapter will be
devoted to a study of disk I/O efficiency.

• The other major objective is generality. In the interests of simplicity and freedom
from error, it is desirable to handle all devices in a uniform manner.This statement
applies both to the way in which processes view I/O devices and the way in which
the operating system manages I/O devices and operations.
Logical Structure of the I/O
Function
• The details of the organization will depend on the type of device and the
application. The three most important logical structures are presented in the
figure.Of course, a particular operating system may not conform exactly to
these structures.However, the general principles are valid, and most operating
systems approach I/O in approximately this way. Let us consider the simplest
case first, that of a local peripheral device that communicates in a simple
fashion, such as a stream of bytes or records. The following layers are
involved:
• Logical I/O: The logical I/O module deals with the device as a
logical resource and is not concerned with the details of
actually controlling the device.
• Device I/O: The requested operations and data (buffered
characters, records, etc.) are converted into appropriate
sequences of I/O instructions, channel commands,and
controller orders.
• Scheduling and control: The actual queuing and scheduling of
I/O operations occurs at this layer, as
well as the control of the
operations.Thus, interrupts are handled
at this layer and I/O status is collected
and reported.This is the layer of
software that actually interacts with the
I/O module and hence the hardware.
I/O BUFFERING
 A block-oriented device stores information in blocks
that are usually of fixed size, and transfers are
made one block at a time. Generally, it is possible to
reference data by its block number. Disks and USB keys
are examples of block-oriented devices

 A stream-oriented device transfers data in and out


as a stream of bytes,with no block
structure.Terminals, printers, communications
ports,mouse and other pointing devices, and most other
devices that are not secondary storage are stream
oriented.
Single Buffer
• When a user process issues an I/O request, the operating system
assigns a buffer in the system portion of main memory to the
operation. For block-oriented devices, the single buffering scheme can
be described as follows: Input transfers are made to the system
buffer.When the transfer is complete, the process moves the block into
user space and immediately requests another block.This is called
reading ahead, or anticipated input

• In the case of line-at-a-time I/O, the buffer can be used to hold a


single line. The user process is suspended during input, awaiting the
arrival of the entire line. For output, the user process can place a line
of output in the buffer and continue processing. It need not be
suspended unless it has a second line of output to send before the
buffer is emptied from the first output operation.
Double Buffer

• An improvement over single buffering can be had by assigning two system


buffers to the operation (Figure 11.5c).A process now transfers data to (or
from) one buffer while the operating system empties (or fills) the other.
This technique is known as double buffering or buffer swapping.

• For block-oriented transfer, we can roughly estimate the execution time as


max [C, T].

• For stream-oriented input, we again are faced with the two alternative
modes of operation. For line-at-a-time I/O, the user process need not be
suspended for input or output, unless the process runs ahead of the double
buffers.
Circular Buffer

• A double-buffer scheme should smooth out the flow of data between an


I/O device and a process. If the performance of a particular process is the
focus of our concern, then we would like for the I/O operation to be able to
keep up with the process. Double buffering may be inadequate if the
process performs rapid bursts of I/O. In this case, the problem can often be
alleviated by using more than two buffers.

• When more than two buffers are used, the collection of buffers is itself
referred to as a circular buffer (Figure 11.5d), with each individual buffer
being one unit in the circular buffer.
DISK SCHEDULING
Disk Performance Parameters

• The actual details of disk I/O operation depend on the computer system, the
operating system, and the nature of the I/O channel and disk controller hardware.

• When the disk drive is operating, the disk is rotating at constant speed.To read or
write, the head must be positioned at the desired track and at the beginning of the
desired sector on that track. Track selection involves moving the head in a
movablehead system or electronically selecting one head on a fixed-head system.
On a movable-head system, the time it takes to position the head at the track is
known as seek time.
Disk Scheduling Policies

• Consider the typical situation in a multiprogramming environment, in which


the operating system maintains a queue of requests for each I/O device. So,
for a single disk, there will be a number of I/O requests (reads and writes)
from various processes in the queue. If we selected items from the queue in
random order, then we can expect that the tracks to be visited will occur
randomly, giving poor performance. This random scheduling is useful as a
benchmark against which to evaluate other techniques.

• Figure 11.7 compares the performance of various scheduling algorithms for


an example sequence of I/O requests.The vertical axis corresponds to the
tracks on the disk. The horizontal access corresponds to time or,
equivalently, the number of tracks traversed.
First-In-First-Out

• The simplest form of scheduling is first-in-first-out (FIFO) scheduling, which


processes items from the queue in sequential order. This strategy has the
advantage of being fair, because every request is honored and the requests
are honored in the order received. Figure 11.7a illustrates the disk arm
movement with FIFO

• With FIFO, if there are only a few processes that require access and if many
of the requests are to clustered file sectors, then we can hope for good
performance. However, this technique will often approximate random
scheduling in performance, if there are many processes competing for the
disk.
Priority

• With a system based on priority (PRI), the control of the


scheduling is outside the control of disk management software.
Such an approach is not intended to optimize disk utilization
but to meet other objectives within the operating system.
Often short batch jobs and interactive jobs are given higher
priority than longer jobs that require longer computation.This
allows a lot of short jobs to be flushed through the system
quickly and may provide good interactive response time
Last In First Out

• In transaction processing systems, giving the device to the most recent user
should result in little or no arm movement for moving through a sequential
file. Taking advantage of this locality improves throughput and reduces
queue lengths.As long as a job can actively use the file system, it is
processed as fast as possible.

• FIFO, priority, and LIFO (last in first out) scheduling are based solely on
attributes of the queue or the requester. If the scheduler knows the current
track position, then scheduling based on the requested item can be
employed.We examine these policies next.
Shortest Service Time First

• The SSTF policy is to select the disk I/O request that requires
the least movement of the disk arm from its current position.
Thus, we always choose to incur the minimum seek time.

• Figure 11.7b and Table 11.2b show the performance of SSTF on


the same example as was used for FIFO.The first track accessed
is 90, because this is the closest requested track to the starting
position.
SCAN

• With SCAN, the arm is required to move in one direction only, satisfying all
outstanding requests en route, until it reaches the last track in that direction or
until there are no more requests in that direction.This latter refinement is
sometimes referred to as the LOOK policy. The service direction is then reversed
and the scan proceeds in the opposite direction, again picking up all requests in
order.

• As can be seen, the SCAN policy behaves almost identically with the SSTF policy.
Indeed, if we had assumed that the arm was moving in the direction of lower
track numbers at the beginning of the example, then the scheduling pattern
would have been identical for SSTF and SCAN.

• With SCAN, if the expected time for a scan from inner track to outer track is t,
then the expected service interval for sectors at the periphery is 2t
C-SCAN

• The C-SCAN (circular SCAN) policy restricts scanning to one


direction only.Thus, when the last track has been visited in one
direction, the arm is returned to the opposite end of the disk
and the scan begins again.This reduces the maximum delay
experienced by new requests.

• With C-SCAN, the interval is on the order of where smax


is the maximum seek time.
N-step-SCAN and FSCAN

• With SSTF, SCAN, and C-SCAN, it is possible that the arm may not move for a
considerable period of time. For example, if one or a few processes have high
access rates to one track, they can monopolize the entire device by repeated
requests to that track. High-density multi surface disks are more likely to be affected
by this characteristic than lower-density disks and/or disks with only one or two
surfaces. To avoid this “arm stickiness,” the disk request queue can be segmented,
with one segment at a time being processed completely. Two examples of this
approach are N-step-SCAN and FSCAN.

• FSCAN is a policy that uses two subqueues. When a scan begins, all of the requests
are in one of the queues, with the other empty. During the scan, all new requests
are put into the other queue.Thus, service of new requests is deferred until all of the
old requests have been processed.

You might also like