Operating
Systems:
Internals Module 6
and
Design I/O Management
Principles and Disk Scheduling
Seventh Edition
By William Stallings
Operating Systems:
Internals and Design Principles
An artifact can be thought of as a meeting point—an
“interface” in today’s terms between an “inner”
environment, the substance and organization of the artifact
itself, and an “outer” environment, the surroundings in
which it operates. If the inner environment is appropriate to
the outer environment, or vice versa, the artifact will serve its
intended purpose.
— THE SCIENCES OF THE ARTIFICIAL,
Herbert Simon
External devices that engage in I/O with computer
systems can be grouped into three categories:
Human readable
• suitable for communicating with the computer user
• printers, terminals, video display, keyboard, mouse
Machine readable
• suitable for communicating with electronic equipment
• disk drives, USB keys, sensors, controllers
Communication
• suitable for communicating with remote devices
• modems, digital line drivers, network interface card (NIC)
Devices differ in a number of areas:
Data Rate
• there may be differences of magnitude between the data transfer rates
Application
• the use to which a device is put has an influence on the software
Complexity of Control
• the effect on the operating system is filtered by the complexity of the I/O module that controls the device
Unit of Transfer
• data may be transferred as a stream of bytes or characters or in larger blocks
Data Representation
• different data encoding schemes are used by different devices
Error Conditions
• the nature of errors, the way in which they are reported, their consequences, and
the available range of responses differs from one device to another
Three techniques for performing I/O are:
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
if non-blocking – processor continues to execute instructions from the process
that issued the I/O command
if blocking – the next instruction 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
Techniques for Performing I/O
• Processor directly controls a peripheral device
1
• A controller or I/O module is added
2
• Same configuration as step 2, but now interrupts are employed
3
• The I/O module is given direct control of memory via DMA
4
• The I/O module is enhanced to become a separate processor, with a
5 specialized instruction set tailored for I/O
• The I/O module has a local memory of its own and is, in fact, a
6 computer in its own right
The actual details of disk I/O
Disk
operation depend on the:
computer system
Performance operating system
nature of the I/O
Parameters 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 movable-head 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
The time it takes for the beginning of the sector to reach the head is
known as rotational delay
The sum of the seek time and the rotational delay equals the access
time
First-In, First-Out (FIFO)
Processes in sequential order
Fair to all processes
Approximates random scheduling in performance
if there are many processes competing for the disk
55, 58, 39, 18, 90, 160, 150, 38, 184
Select the disk I/O request
Shortest Service that requires the least
movement of the disk arm
Time First from its current position
(SSTF) Always choose the
minimum seek time
55, 58, 39, 18, 90, 160, 150, 38, 184
Also known as the elevator algorithm
Arm moves in one direction only
satisfies all outstanding requests until it reaches
SCAN
the last track in that direction or no more
requests in the direction (LOOK), then the
direction is reversed
does NOT exploit locality (i.e., against the area
recently traversed)
Favors (1) jobs whose requests are for tracks
nearest to both innermost and outermost tracks,
and (2) latest-arriving jobs
55, 58, 39, 18, 90, 160, 150, 38, 184
Restricts scanning to one
C-SCAN direction only
When the last track has been
(Circular SCAN) visited in one direction, the arm
is returned to the opposite end of
the disk and the scan begins
again
55, 58, 39, 18, 90, 160, 150, 38, 184