OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

50
OPERATING SYSTEMS OPERATING SYSTEMS CS3502 CS3502 Fall 2015 Fall 2015 Input/Output System Input/Output System Chapter 9 Chapter 9

Transcript of OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Page 1: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

OPERATING SYSTEMSOPERATING SYSTEMSCS3502CS3502

Fall 2015Fall 2015

Input/Output SystemInput/Output System

Chapter 9Chapter 9

Page 2: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 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.

Page 3: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 4: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Disk Drive MechanismDisk Drive Mechanism

Page 5: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 6: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 7: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 8: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 9: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 10: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 11: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 12: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 13: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 14: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 15: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 16: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 17: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 18: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 19: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 20: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Disk Track FormatDisk Track Format

Page 21: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 22: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 23: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Stages of an I/O RequestStages of an I/O Request

Page 24: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 25: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

I/O Request QueueingI/O Request Queueing

Page 26: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 27: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 28: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 29: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 30: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 31: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 32: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 33: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 34: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 35: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 36: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 37: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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

Page 38: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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)

Page 39: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 40: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

FCFS Scheduling ExampleFCFS Scheduling Example

Page 41: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Another Example with FCFSAnother Example with FCFS

Illustration shows total head movement of 640 cylinders.

Page 42: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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).

Page 43: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

SSTF Scheduling ExampleSSTF Scheduling Example

Page 44: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Another Example with SSTFAnother Example with SSTF

Page 45: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 46: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Example with SCAN SchedulingExample with SCAN Scheduling

Page 47: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Another Example with SCANAnother Example with SCAN

Page 48: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.

Page 49: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

Example with C-SCANExample with C-SCAN

Page 50: OPERATING SYSTEMS CS3502 Fall 2015 OPERATING SYSTEMS CS3502 Fall 2015 Input/Output System Chapter 9.

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.