Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

33
Chapter 11 1 Input/Output Management and Input/Output Management and Disk Scheduling Disk Scheduling Chapter 11 Chapter 11

Transcript of Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Page 1: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 111

Input/Output Management and Input/Output Management and Disk SchedulingDisk Scheduling

Chapter 11 Chapter 11

Page 2: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 112

Categories of I/O devicesCategories of I/O devices

Human-readable: printers video display keyboard...

Machine Readable: disk, tape sensors...

Communication line drivers modems...

Page 3: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 113

Main CharacteristicsMain Characteristics

Data rate (bits or bytes?) Unit of transfer (bit, byte, or block) Data format Error conditions Interrupt signaling

Page 4: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 114

Varying data rates....Varying data rates....

Page 5: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 115

Stages of EvolutionStages of Evolution

No interrupts Simple programmed I/O by CPU Add simple controller to this: channel;

busy waiting or polling needed CPU keeps asking channel whether it has finished

With interrupts Add interrupts to this

simultaneous operation CPU & I/O traffic I/O Memory still goes through CPU

Introduce DMA: a controller to minimize CPU involvement. CPU interrupted only after entire block has been transferred DMA has complex instruction set (e.g. “if”) DMA is complete separate CPU

Page 6: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 116

Direct Memory AccessDirect Memory Access

Takes control of the system from the CPU to transfer data to and from memory over the system bus

Cycle stealing is used to transfer data on the system bus CPU slowed down, but not as much as it would be

without DMA The CPU pauses one bus cycle to allow DMA

to do its work No interrupts occur until all data block

transferred

Page 7: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 117

Possible DMA configuration 1 Possible DMA configuration 1 (communication unit/DMA involves bus: inefficient)(communication unit/DMA involves bus: inefficient)

Page 8: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 118

Possible DMA configuration 2Possible DMA configuration 2(communication betw. DMA and unit does not involve bus)(communication betw. DMA and unit does not involve bus)

Page 9: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 119

Possible DMA configuration 3Possible DMA configuration 3(very flexible, facilitates the inclusion of additional I/O units)(very flexible, facilitates the inclusion of additional I/O units)

Page 10: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1110

OS Design IssuesOS Design Issues

Efficiency I/O is usually the bottleneck! Extremely slow

with respect to CPU Generality:

Try to handle devices as much as possible in same manner

Use general-purpose primitives, hide peculiarities of devices from high-level modules every file can be treated in terms of read. write,

open, close, lock, unlock...

Page 11: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1111

Layering Models

Lower levels hide details from higher ones

Page 12: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1112

I/O BufferingI/O Buffering

Could buffer be in memory area of user process? Probably not. Process in execution is subject to

paging, suspension, etc. so I/O must occur in a separate memory area (next

solution)

Page 13: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1113

I/O BufferingI/O Buffering

Block-Oriented Information is stored in fixed sized blocks Transfers are made a block at the time Used for disks and tapes

Stream-oriented Information unit is of variable size: a stream of bytes

special info, such as carriage return, will delimit its logical parts

Used for terminals, printers, communication ports, mouse and most other devices that are not secondary storage

Page 14: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1114

Single BufferSingle Buffer

Block-oriented Input transfers made to buffer As soon as user takes data, new input can start

(similarly for output) Read ahead, output and go (no wait)

Page 15: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1115

Double bufferingDouble buffering

More independence between I/O and processing: a process can use the content of one buffer while the I/O device works with the other buffer

Normally invisible to programmer.

Shadow

Page 16: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1116

Circular bufferCircular buffer

Generalized scheme, such as in the producer-consumer problem

Sometimes the I/O device can be faster, other times the user process can be faster

Peak demands are smoothed out

Page 17: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1117

Disk schedulingDisk scheduling

Cylinder: the set of tracks that are in the same position with respect to read/write head (but book only considers tracks, not cylinders)

Silberschatz

Page 18: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1118

Disk performance parametersDisk performance parameters

To read or write, the disk head must be positioned at the desired track and at the beginning of the desired sector

Access time is the sum of: Seek time

time it takes to position the head at the desired track (or cylinder)

Rotational delay or rotational latency time its takes for the beginning of the sector to reach the

head Transfer time

Seek time >> Rotational Delay >> Transfer time

Page 19: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1119

Page 20: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1120

Tracks and cylinders

Page 21: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1121

Page 22: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1122

Timing of a Disk I/O TransferTiming of a Disk I/O Transfer

Page 23: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1123

Disk Scheduling PoliciesDisk Scheduling Policies

Seek time is the reason for differences in performance Seek time >> Rotational latency

For a single disk there will be a number of I/O requests If requests are selected randomly, we will not get a

good performance we will assume that the requests for disk access of a

number of user will be random (but for a single user `locality of reference’ will again hold)

So it is important to devise better methods: I/O system sorts the requests in some way

Page 24: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1124

Evaluating the policiesEvaluating the policies

To evaluate the policies, we will use a random sequence of track accesses (see book): Starting at track 100 and then

55 58 39 18 90 160 150 38 184

and calculate how many track traversal each policy will require to finish the sequence

Page 25: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1125

FIFO policy: FIFO policy: process requests in the order they arriveprocess requests in the order they arrive

From 100 to 55: 45 tracks traversed From 55 to 58: 3 tracks traversed From 58 to 39: 19 tracks traversed etc etc.... In total: 45+3+19... = 498 tracks 498 / 9 = 55.3 tracks traversed for the avg request

55 58 39 18 90 160 150 38 184

Page 26: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1126

The Shortest Service Time First policy (SSTF)The Shortest Service Time First policy (SSTF)

This policy looks each time at the queue of the waiting requests and chooses the one that can be served with the shortest seek from the current position.

From 100 to 90: 10 tracks From 90 to 58: 32 From 58 to 55: 3 In total: 10+32+3... = 248 / 9 = 27.5 better!

55 58 39 18 90 160 150 38 184

90 58 55 39 38 18 150 160 184

Page 27: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1127

The SCAN (or The SCAN (or elevatorelevator) policy ) policy

Problem with the previous policy: it is possible that some requests will starve, because closer requests keep arriving!!

Solution: keep going in one direction until all requests are satisfied. Then change direction, and so on

100 150 = 50; 150 160 = 10; 160 184 = 24; 184 90 = 94.... 50+10+24+94+.... = 250 / 9 = 27.8 a bit worse than SSTF but no

starvation

55 58 39 18 90 160 150 38 184

150 160 184 90 58 55 39 38 18

Page 28: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1128

C-SCAN (Circular SCAN)C-SCAN (Circular SCAN)

Similar behavior to SSTF Problem with the previous policy:

nothing to do immediately after the arm reverses direction (already done)

waiting requests will be at the other end C-SCAN: assumes that return trip to track is

rapid (as it is in many drivers) Disk is always scanned in one direction only When the scan is complete, arm goes back

to the beginning and restarts

Page 29: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1129

C-SCAN (Circular SCAN)C-SCAN (Circular SCAN)

If the return home is considered as 184-18=166 then the average seek length is 35.8.

If it is considered 0, then 136 / 9 = 15 (only!) In practice, it will be closer to 35 than to 15.

return home

184

18

55 58 39 18 90 160 150 38 184

150 160 184 18 38 39 55 58 90

Page 30: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1130

Last in, First Out (LIFO)Last in, First Out (LIFO)

Serve always the most recent request first! Rationale: keep serving the same user may

result in accessing nearby tracks certainly true if file is sequential applies the principle of locality to disk accesses

But may starve early users

Page 31: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1131

Page 32: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1132

In practice...In practice...

For a realistic evaluation of disk times, one cannot assume simply that traversal of one track takes one unit of time

One must consider real arm motion times, which include a start time when the head picks up speed

One must also consider rotational delay and read times

Such times vary from disk unit to disk unit

Page 33: Chapter 11 1 Input/Output Management and Disk Scheduling Chapter 11.

Chapter 1133

Important Concepts of Chapter 11Important Concepts of Chapter 11

Different types of I/O Devices Different types of I/O Processing Direct Memory Access Buffering Characteristics of disk units Access time Different disk scheduling algorithms

comparison