OPERATING SYSTEMS CS3530 Summer 2014 OPERATING SYSTEMS CS3530 Summer 2014 Input/Output System...
-
Upload
efren-herrod -
Category
Documents
-
view
214 -
download
0
Transcript of OPERATING SYSTEMS CS3530 Summer 2014 OPERATING SYSTEMS CS3530 Summer 2014 Input/Output System...
OPERATING SYSTEMSOPERATING SYSTEMSCS3530CS3530
Summer 2014Summer 2014
Input/Output SystemInput/Output System
Chapter 9Chapter 9
Input/Output SystemInput/Output System
Major objectives:Major objectives:
An application’s I/O requests are sent to An application’s I/O requests are sent to the I/O device. the I/O device.
Take whatever response comes back from Take whatever response comes back from the device and send it to the application.the device and send it to the application.
Optimize the performance of processing Optimize the performance of processing the various I/O requests.the various I/O requests.
General I/O IssuesGeneral I/O Issues
The operating system is able to improve overall The operating system is able to improve overall system performance if it can keep the various system performance if it can keep the various devices as busy as possible.devices as busy as possible.
It is important for the operating system to handle It is important for the operating system to handle device interrupts as quickly as possible.device interrupts as quickly as possible.
Disk StructureDisk Structure
Disk drives are addressed as large 1-dimensional Disk drives are addressed as large 1-dimensional arrays of arrays of logical blockslogical blocks, where the logical block is , where the logical block is the smallest unit of transfer. the smallest unit of transfer.
The 1-dimensional array of logical blocks is The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially.mapped into the sectors of the disk sequentially.– Sector 0 is the first sector of the first track on the Sector 0 is the first sector of the first track on the
outermost cylinder.outermost cylinder.– Mapping proceeds in order through that track, then the Mapping proceeds in order through that track, then the
rest of the tracks in that cylinder, and then through the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost.rest of the cylinders from outermost to innermost.
Direct Access Storage DevicesDirect Access Storage Devices
Otherwise known as DASDsOtherwise known as DASDs– Devices that can directly read or write to a Devices that can directly read or write to a
specific place on a disk or drumspecific place on a disk or drum– Also known as random access storage devicesAlso known as random access storage devices
Grouped into two major categoriesGrouped into two major categories– fixed read/write headsfixed read/write heads– movable read/write headsmovable read/write heads
Fixed-Head DrumsFixed-Head Drums
Developed in the early 1950sDeveloped in the early 1950s– access times of 5 to 25 ms were considered fastaccess times of 5 to 25 ms were considered fast– used a drum with a capacity of 2000 bytes used a drum with a capacity of 2000 bytes
» later increased to 4000 byteslater increased to 4000 bytes
» speed was 200 rpmspeed was 200 rpm
» much faster than other drums of the time which much faster than other drums of the time which were only 50-60 rpmwere only 50-60 rpm
By 1970 drums increased to 1 megabyte By 1970 drums increased to 1 megabyte and speed of 3000 rpmand speed of 3000 rpm
Fixed-Head DrumsFixed-Head Drums
The device is formatted so tracks run The device is formatted so tracks run around itaround it
Data recorded serially on each track by the Data recorded serially on each track by the read/write head positioned over itread/write head positioned over it
These drums were quite fast, yet expensive These drums were quite fast, yet expensive and did store as much as other DASDs.and did store as much as other DASDs.
Fixed-Head DisksFixed-Head Disks Disks resemble phonograph record albums Disks resemble phonograph record albums
covered with magnetic film that has been covered with magnetic film that has been formatted into concentric circles called formatted into concentric circles called trackstracks
Data is recorded in the same manner as Data is recorded in the same manner as fixed-head drumfixed-head drum
These were very expensive and had less These were very expensive and had less storage space as compared to movable-head storage space as compared to movable-head disks but were faster.disks but were faster.
Movable-Head DrumsMovable-Head Drums
Consist of a few read/write heads that move Consist of a few read/write heads that move from track to track to cover the entire from track to track to cover the entire surface of the drumsurface of the drum
Device that is least expensive has only one Device that is least expensive has only one read/write head for the whole drumread/write head for the whole drum
Drums with several read/write heads work Drums with several read/write heads work faster but also cost morefaster but also cost more
Movable-Head DisksMovable-Head Disks
The read/write head floats over the surface of The read/write head floats over the surface of the diskthe disk
Exist as individual units, as in a PCExist as individual units, as in a PC Can also be in a Can also be in a disk packdisk pack, which is a stack , which is a stack
of disksof disks
Disk PackDisk Pack
A typical disk pack consists of several platters A typical disk pack consists of several platters that are stacked on a common central that are stacked on a common central spindle, with a slight space between them spindle, with a slight space between them so the read/write heads can move between so the read/write heads can move between the pairs of disks.the pairs of disks.
Architecture of M-Head DisksArchitecture of M-Head Disks
Each platter has two surfaces for recording, Each platter has two surfaces for recording, except the top and bottomexcept the top and bottom
Each Each surfacesurface is formatted with specific is formatted with specific numbers of numbers of trackstracks for the data to be for the data to be recorded onrecorded on– number of tracks varies depending on the number of tracks varies depending on the
manufacturermanufacturer– usually range from 200 to 800 tracksusually range from 200 to 800 tracks
Optical StorageOptical Storage Direct access storageDirect access storage CD-ROMs contained the first optical storage CD-ROMs contained the first optical storage
DASDs DASDs – these were incompatible with most systems, as these were incompatible with most systems, as
they were developed for a single systemthey were developed for a single system Is a major contender for the replacement of Is a major contender for the replacement of
magnetic disks because it has high-density magnetic disks because it has high-density storage and durabilitystorage and durability
Function of Optical DiscFunction of Optical Disc
Optical disc drive functions similar to the Optical disc drive functions similar to the magnetic disk drivemagnetic disk drive
Read head is on an arm that moves forward Read head is on an arm that moves forward and backward, track to trackand backward, track to track– disc rotates at 200-500 rpmdisc rotates at 200-500 rpm– average seek time is 500 ms and maximum seek average seek time is 500 ms and maximum seek
is 1 secondis 1 second– transfer rate is about 150 kilobytes/secondtransfer rate is about 150 kilobytes/second
CD Storage CapacityCD Storage Capacity
CD-ROM has large storage potential, CD-ROM has large storage potential, more than 700 megabytes of datamore than 700 megabytes of data
Disk Structure and OrganizationDisk Structure and Organization
Moving-head disk - one head per surfaceMoving-head disk - one head per surface Fixed-head disk - one head per trackFixed-head disk - one head per track Data on a disk is addressed by:Data on a disk is addressed by:
– CylinderCylinder– SurfaceSurface– SectorSector
Timings in a Disk RequestTimings in a Disk Request
The disk request timing is the sum of:The disk request timing is the sum of: Seek time - arm positioning delaySeek time - arm positioning delay Latency time - rotational delayLatency time - rotational delay Data transfer timeData transfer time
Read/WriteRead/Write
To read or write data, disk device must To read or write data, disk device must move the armmove the arm to to the appropriate track. the appropriate track.
The time to carry this out this is called The time to carry this out this is called Seek TimeSeek Time. . Then, the disk device must wait for the desired Then, the disk device must wait for the desired
sector/data to rotate into position under the head sector/data to rotate into position under the head (rotational latency).(rotational latency).
Each track is recorded in units called Each track is recorded in units called sectorssectors. . A sector is the A sector is the smallest amount of datasmallest amount of data that can be that can be
physically read or written.physically read or written.
Disk Access TimeDisk Access Time
The disk access time can be calculated as The disk access time can be calculated as follows:follows:
Disk Access time = Disk Access time =
Seek time + Rotational Latency Seek time + Rotational Latency
I/O RequestsI/O Requests
In general, there may be many I/O requests In general, there may be many I/O requests sent to an I/O device at the same time. sent to an I/O device at the same time.
These requests may come from multiple These requests may come from multiple processes or the same process.processes or the same process.
I/O Device HandlingI/O Device Handling
A Queue of Pending RequestsA Queue of Pending Requests A Resource Scheduler that determines the A Resource Scheduler that determines the
next request to executenext request to execute A Mechanism to initiate the next request A Mechanism to initiate the next request
whenever a request completes.whenever a request completes.
I/O Performance OptimizationI/O Performance Optimization
I/O processing is much slower than CPU I/O processing is much slower than CPU processing. Every physical disk I/O has a processing. Every physical disk I/O has a dramatic impact on system performancedramatic impact on system performance
To improve I/O performance:To improve I/O performance:– Reduce the number of I/O requestsReduce the number of I/O requests– Carry out buffering and/or cachingCarry out buffering and/or caching– I/O SchedulingI/O Scheduling
Buffering and CachingBuffering and Caching
The I/O system should make the physical I/O The I/O system should make the physical I/O requests as big as possible.requests as big as possible.
This will reduce the number of physical I/O This will reduce the number of physical I/O requests by the requests by the buffering factorbuffering factor used. used.
The application's logical I/O requests should The application's logical I/O requests should copy data to/from a large memory buffer. The copy data to/from a large memory buffer. The physical I/O requests then transfer the entire physical I/O requests then transfer the entire buffer. buffer.
I/O SchedulingI/O Scheduling
For most devices, a FCFS (First-Come-First-For most devices, a FCFS (First-Come-First-Serve) scheduling algorithm is appropriate. For Serve) scheduling algorithm is appropriate. For example, one wants the segments of a music file example, one wants the segments of a music file to be played in sequential order. to be played in sequential order.
For some devices (For some devices (disksdisks especially), the order in especially), the order in which requests are processed is not inherently which requests are processed is not inherently constrained by the device characteristics. constrained by the device characteristics.
I/O Scheduling (Cont.)I/O Scheduling (Cont.)
On a typical system, there will be pending disk On a typical system, there will be pending disk I/O requests from many different Processes. I/O requests from many different Processes.
The correct functioning of these processes The correct functioning of these processes usually does not depend on the usually does not depend on the orderorder in which in which the disk I/O operations actually occur. the disk I/O operations actually occur.
Thus, the Resource Scheduler attempts to Thus, the Resource Scheduler attempts to optimize performanceoptimize performance for devices such as for devices such as disks.disks.
Context Switching in I/OContext Switching in I/O
In In CPU schedulingCPU scheduling, the context-switch time , the context-switch time is relatively small with respect to the is relatively small with respect to the service timeservice time
In In I/O schedulingI/O scheduling the context-switch time is the context-switch time is relatively large with respect to the service relatively large with respect to the service timetime
The time to move the R/W head between The time to move the R/W head between cylinders is much greater than the time it cylinders is much greater than the time it takes to read or write to a cylindertakes to read or write to a cylinder
Goal of Disk SchedulingGoal of Disk Scheduling
In any disk system with a moving read/write In any disk system with a moving read/write head, the head, the seek timeseek time between cylinders takes a between cylinders takes a significant amount of timesignificant amount of time
This traveling head time should be minimizedThis traveling head time should be minimized
An AnalogyAn Analogy
Traveling service person --- a technician Traveling service person --- a technician who has to service requests from several who has to service requests from several clients in a geographical areaclients in a geographical area
Normally the service person spends more Normally the service person spends more time driving than actually carrying out the time driving than actually carrying out the service tasksservice tasks
Purpose of Disk SchedulingPurpose of Disk Scheduling
Select a disk request from the queue of I/O Select a disk request from the queue of I/O requestsrequests
Decide when to process this I/O requestDecide when to process this I/O request
Issues in Disk SchedulingIssues in Disk Scheduling
ThroughputThroughput - the number of disk requests - the number of disk requests that are completed in some periodthat are completed in some period
FairnessFairness - some disk requests may have to - some disk requests may have to wait a relatively long time before being wait a relatively long time before being servedserved
A totally fair system would ensure that the A totally fair system would ensure that the mean response time of the disk requests is mean response time of the disk requests is the same for all processesthe same for all processes
Goal of Disk Scheduling?Goal of Disk Scheduling?
High ThroughputHigh Throughput FairnessFairness
There is a trade-off between total system There is a trade-off between total system throughput and fairnessthroughput and fairness
State-Dependent BehaviorState-Dependent Behavior
The current position of the read/write The current position of the read/write head (i.e., the state of the disk) affects head (i.e., the state of the disk) affects the response time of the next requestthe response time of the next request
Disk Scheduling AlgorithmsDisk Scheduling Algorithms
For moving-head disk, disk scheduling algorithms For moving-head disk, disk scheduling algorithms are needed to minimize seek time are needed to minimize seek time
FCFS scheduling: first-come-first-servedFCFS scheduling: first-come-first-served SSTF scheduling: shortest-seek-time-firstSSTF scheduling: shortest-seek-time-first SCAN schedulingSCAN scheduling C-SCAN scheduling: circular SCANC-SCAN scheduling: circular SCAN LOOK schedulingLOOK scheduling C-LOOK schedulingC-LOOK scheduling
Disk Scheduling AlgorithmsDisk Scheduling Algorithms
Several algorithms exist to schedule the Several algorithms exist to schedule the servicing of disk I/O requests. servicing of disk I/O requests.
Given the following disk request sequence for a Given the following disk request sequence for a disk with 100 tracks:disk with 100 tracks:
44, 20, 95, 4, 50, 52, 47, 61, 87, 2544, 20, 95, 4, 50, 52, 47, 61, 87, 25
Head pointer 50 (current position of R/W heads)Head pointer 50 (current position of R/W heads)
FCFS SchedulingFCFS Scheduling
FCFS scheduling service I/O requests in the FCFS scheduling service I/O requests in the order in which they arrive. order in which they arrive.
It is, of course, the simplest scheduling It is, of course, the simplest scheduling algorithm and actually does no scheduling.algorithm and actually does no scheduling.
It serves as a useful baseline to compare It serves as a useful baseline to compare other scheduling algorithms. other scheduling algorithms.
Another Example with FCFSAnother Example with FCFS
Illustration shows total head movement of 640 cylinders.
SSTFSSTF
Selects the request with the minimum seek time Selects the request with the minimum seek time from the current head position.from the current head position.
SSTF scheduling is a form of SJF scheduling; SSTF scheduling is a form of SJF scheduling; may cause starvation of some requests.may cause starvation of some requests.
Illustration shows total head movement of 152 Illustration shows total head movement of 152 cylinders (or tracks).cylinders (or tracks).
SCANSCAN
The disk arm starts at one end of the disk, and The disk arm starts at one end of the disk, and moves toward the other end, servicing requests moves toward the other end, servicing requests until it gets to the other end of the disk, where until it gets to the other end of the disk, where the head movement is reversed and servicing the head movement is reversed and servicing continues.continues.
Sometimes called the Sometimes called the elevator algorithmelevator algorithm.. Illustration shows total head movement of 136 Illustration shows total head movement of 136
cylinders.cylinders.
C-SCANC-SCAN
A variant of SCANA variant of SCAN Provides a more uniform wait time than SCAN.Provides a more uniform wait time than SCAN. The head moves from one end of the disk to the The head moves from one end of the disk to the
other. servicing requests as it goes. When it other. servicing requests as it goes. When it reaches the other end, however, it immediately reaches the other end, however, it immediately returns to the beginning of the disk, without returns to the beginning of the disk, without servicing any requests on the return trip.servicing any requests on the return trip.
C-LOOKC-LOOK
Variant of C-SCANVariant of C-SCAN Disk arm only travels as far as the last Disk arm only travels as far as the last
request in each direction, then reverses request in each direction, then reverses direction immediately, without first going all direction immediately, without first going all the way to the end of the disk. the way to the end of the disk.