INPUT/OUTPUT
CHAPTER #
10
Operating Systems
Chapter 10 - Outline
SHEHERYAR MAL
IK
Input/Output organization
Objectives of I/O system
Unix I/O system
MS-DOS I/O system
Device drivers in windows
Disk structure
Seek time
Latency
Disk scheduling
FCFS
SSTF
Scan scheduling
Chapter # 10 Operating Systems 2
Input/Output Organization
SHEHERYAR MAL
IK
Input/output systems is one of the important part of system like
processor and memory
It is least satisfactory system because of its slowness and lack of
consistency
Mode of operation of I/O devices is different, it is difficult for
operating system to handle with any generality
The computer communicates with I/O devices by mean of an I/O bus
system
Each I/O device has an associated hardware controller attached to this
bus system
I/O device performs its activity independently of and with the
processor activity
Most computers use a better technique of direct memory access
(DMA) which offers faster data rates
Chapter # 10 Operating Systems 3
Characteristics of I/O devices
SHEHERYAR MAL
IK
Data rate
Disk: 2Mbytes/sec
Keyboard: 10-15bytes/sec
Unit of transfer
Disk: blocks (e.g. block of 1024bytes)
Screen: single character
Operations
Disk: read, write, seek etc
Printer: write, move paper
Error conditions
Disk: read errors
Printer: paper out
Chapter # 10 Operating Systems 4
Structure of I/O System
SHEHERYAR MAL
IK
The I/O system consist of a number of layers separating the user
at one end and the physical devices to other end
Application Program
An I/O activity is expressed within the application
Such high level language instructions are translated into corresponding
system calls which invoke operating system functions
Input/output Control System (IOCS)
Part of the operating system which deals with I/O related system calls
It performs initial processing and validation on the request and routes
it to appropriate handler (device driver) at the next stage
It is also where the general management of I/O interrupts takes place
Chapter # 10 Operating Systems 5
Structure of I/O System
SHEHERYAR MAL
IK
Device Drivers
It is a software module which manages the communication with, and
control of a specific I/O device
It converts user’s logical request into specific commands directed to
the device
Device Controllers
A device controller is a hardware unit attached to the I/O bus of the
computer
It provides a hardware interface between the computer and the I/O
device
Device
I/O devices are designed to be used in a wide range of different
computer systems
I/O devices can be categorized into block and character devices
A virtual device is a simulation of an actual device by the operating
system, e.g. print spooler
Chapter # 10 Operating Systems 6
Unix I/O System
SHEHERYAR MAL
IK
Unix kernel treat all I/O devices and files identically
That is, devices are also represented as special files which appear as
entries within the disk directory system
All data transfer between a process and a file or device are
handled as a stream of bytes
The /dev directory holds a list of special files which
correspond to the devices attached to the system
For example:
/dev/console system console
/dev/tty01 user terminal 1
/dev/rmt0 magnetic tape
/dev/dsk/os0 hard disk drive 0
/dev/dsk/f03h 3.1/2 floppy drive
/dev/lp line printer
Chapter # 10 Operating Systems 7
MS DOS I/O System
SHEHERYAR MAL
IK
The early MS-DOS computers had built-in device drivers for
screen, keyboard, magnetic disk, serial port and parallel port
MS-DOS I/O program services have two components
DOS services
Refer to higher level facilities often utilizes the BIOS services
ROM BIOS
Refer to ROM-based set of routines which provide low level services for
managing I/O operations on hardware
IO.SYS file manages the I/O operations of the systems and
corresponds to IOCS
Whereas, MSDOS.SYS file is the main operating system file
DOS standard I/O devices names are
A: first diskette drive
Lpt1: parallel port 1
C: hard disk drive
Chapter # 10 Operating Systems 8
I/O Device Drivers in Windows
SHEHERYAR MAL
IK
In windows device drivers are implemented as
dynamic link libraries (DLL’s)
DLL’s contain shareable code for standard drivers
such as display and keyboard drivers
A new device driver can be loaded without effecting
the earlier one
A range of optional drivers can be made available
The plug & play concept is used to make installation
and configuration easy
Chapter # 10 Operating Systems 9
Disk Structure
SHEHERYAR MAL
IK
Each disk has a flat circular shape
Its surfaces are covered with magnetic material
Data are stored on the surfaces by the read/write
head
The disk surface is divided into concentric tracks
Within a track the information is written in blocks
called sectors
The block is fundamental unit of transfer
Information is stored in form of tiny magnetic spots
A head is moved in and out to access different tracks
Chapter # 10 Operating Systems 10
Moving-head Disk Mechanism
SHEHERYAR MAL
IK
Chapter # 10 Operating Systems 11
Disk Structure
SHEHERYAR MAL
IK
Information on the disk is referenced as by a multi part
address, which includes the drive number, the surface and
the track
The tracks on different surfaces are called a cylinder
The time to read write a disk block is determined by three
factors;
i.e. seek time, latency and actual transfer time
Seek time
It is the time required to move the head to proper track for read/write
operation
Rotational Latency
It is the time to wait for the required block/sector to rotate below the
head
Chapter # 10 Operating Systems 12
Disk Scheduling
SHEHERYAR MAL
IK
When a process needs disk I/O, it issues a system call
to the OS;
If disk is free the request will be served immediately
But, if disk is busy and serving a request , then the
additional request will be queued
There are different approaches to serve disk I/O
requests from the queue
First come first serve (FCFS) scheduling
Shortest seek time first (SSTF) scheduling
Scan scheduling
Chapter # 10 Operating Systems 13
FCFS Scheduling
SHEHERYAR MAL
IK
The request at the head of the queue will be served first
FCFS is the simplest form of the disk scheduling
Its algorithm is easy to implement
Consider a queue of disk requests;
98, 183, 37, 122, 14, 124, 65 and 67
If the reader head is at track 53, it will first move from 53 to 98, then
to 183 and so on
The total head movement is 640 tracks
If the requests for the tracks 37 and 14 could be served together, the
total head movement could be decreased substantially
In this way, the average time to service each request would decrease,
improving disk throughput
Chapter # 10 Operating Systems 14
FCFS Scheduling (5b)
SHEHERYAR MAL
Disk track current location= track no 98 IK
183, 37,53, 122, 14, 124, 65 and 67
Total head tracks = find answer
14 37 53 65 67 98 122 124 183
Chapter # 10 Operating Systems 15
FCFS Scheduling (5b)
Disk track current location= track no 98
183, 37,53, 122, 14, 124, 65 and 67
Find the solution of Total head tracks for the above given
scenario?
Disk track current location= track no 0 and track 400
and track 50
18, 370,153, 12, 14, 112, 300,123,90,87,66,345,234
Find the solution of Total head tracks for the above
given scenario?
SSTF Scheduling
SHEHERYAR MAL
IK
The shortest seek time first disk scheduling algorithm selects the
request with minimum seek time from the current head position
SSTF results in a total head movements of only 236 tracks
Comparing with FCFS, SSTF results in substantial improvements
Assume that we have just two requests in queue, 14 and 186
If a request near 14 are arrives while serving that request, it will be
served next
Request for track 186 may wait indefinitely, if more requests near
14 are arriving continuously
Chapter # 10 Operating Systems 17
SSTF Scheduling (5c)
SHEHERYAR MAL
IK
98, 183, 37, 122, 14, 124, 65 and 67
14 37 53 65 67 98 122 124 183
Chapter # 10 Operating Systems 18
Scan Scheduling
SHEHERYAR MAL
IK
In this algorithm, the head continuously scans the disk from end to
end
The read-write head starts at one end of the disk, and moves towards
the other end
Assume that head is moving from track 53 towards 0, the head
movement would service 37, 14 and then moves to 0
At track 0, the head would reverse and move to other end of the disk
serving requests at 65, 67, 98, 122, 124 and 183
Any new request in front of head will be served immediately
A request just behind the head will have to wit until the head moves
to the end of the disk and reverse its direction
Scan algorithm is also called Elevator algorithm
This algorithm is little bit better than SSTF
Chapter # 10 Operating Systems 19
Scan Scheduling (5c,5d,5a,5B)
SHEHERYAR MAL
IK
98, 183, 37, 122, 14, 124, 65 and 67
14 37 53 65 67 98 122 124 183
Chapter # 10 Operating Systems 20