Chapter 4
This presentation is the property of its rightful owner.
Sponsored Links
1 / 94

Chapter 4 Device Management and Disk Scheduling PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Chapter 4 Device Management and Disk Scheduling. Content. I/O device overview I/O organization and architecture I/O buffering Disk scheduling RAID Notes : Difficult to develop a general, consistent solution. Just a generally discuss. 4.1 I/O Devices (P452). Three categories :

Download Presentation

Chapter 4 Device Management and Disk Scheduling

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Chapter 4 device management and disk scheduling

Chapter 4

Device Management and Disk Scheduling



  • I/O device overview

  • I/O organization and architecture

  • I/O buffering

  • Disk scheduling

  • RAID

  • Notes: Difficult to develop a general, consistent solution. Just a generally discuss.

4 1 i o devices p452

4.1 I/O Devices (P452)

Three categories:

  • Human Readable Devices

    • Such as Keyboard, Mouse, Display, Printer and so on;

  • Machine Readable Devices

    • Such as Actuator, Controller, Sensor, Tape Drive, Disk Drive and so on;

  • Communication Devices

    • Such as Modem, Network Adapter and so on.



  • There are many sorting standard. E.g. data rates

Data rates of devices

Data Rates of Devices

Differences in i o devices

Differences in I/O Devices

  • Application

    • Disk used to store files requires file-management software

    • Disk used to store virtual memory pages needs special hardware and software to support it

    • Terminal used by system administrator may have a higher priority than an ordinary user

Differences in i o devices1

Differences in I/O Devices

  • Complexity of control

  • Unit of transfer

    • Data may be transferred as a stream of bytes for a terminal or in larger blocks for a disk

  • Data representation

    • Encoding schemes

  • Error conditions

    • Devices respond to errors differently

4 2 techniques for performing i o p453 11 2

4.2 Techniques for Performing I/O (p453 11.2)

  • Cyclic Test /Programmed

  • Interrupt-Driven

  • DMA Control

Programmed i o p29

Programmed I/O --P29.

  • I/O module performs the action, not the processor

  • Sets appropriate bits in the I/O status register

  • No interrupts occur

  • Processor checks status until operation is complete

  • Busy-waits

Interrupt driven i o

Interrupt-Driven I/O

  • Processor is interrupted when I/O module ready to exchange data

  • Processor is free to do other work

  • No needless waiting

  • Consumes a lot of processor time because every word read or written passes through the processor

Direct memory access

Direct Memory Access

  • Transfers a block of data directly to or from memory

  • An interrupt is sent when the task is complete

  • The processor is only involved at the beginning and end of the transfer

Evolution of the i o function

Evolution of the I/O Function

  • Processor directly controls a peripheral device

  • Controller or I/O module is added

    • Processor uses programmed I/O without interrupts

    • Processor does not need to handle details of external devices

Evolution of the i o function1

Evolution of the I/O Function

  • Controller or I/O module with interrupts

    • Processor does not spend time waiting for an I/O operation to be performed

  • Direct Memory Access

    • Blocks of data are moved into memory without involving the processor

    • Processor involved at beginning and end only

Evolution of the i o function2

Evolution of the I/O Function

  • I/O channel

    • I/O module is a separate processor. Its with a specialized instruction set tailored(适合) for I/O.

  • I/O processor

    • I/O module has its own local memory

    • Its a computer in its own right

Direct memory access1

Direct 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

  • The instruction cycle is suspended so data can be transferred

  • The CPU pauses one bus cycle

  • No interrupts occur while cycle stealing

    • Do not save context

Direct memory access2

Direct Memory Access

Chapter 4 device management and disk scheduling


  • The Starting location in memory to read from or write to, communicated on the data lines and stored by the DMA module in its address register.

  • The number of words to be read or written, again communicated via the data lines and stored in the data count register.

Dma and interrupt breakpoint

DMA and Interrupt Breakpoint

  • The processor is suspended just before it needs to use the bus. The DMA unit then transfers one word and returns control to the processor.

  • Cycle stealing causes the CPU to execute more slowly.

Dma and interrupt breakpoint1

DMA and Interrupt Breakpoint

Chapter 4 device management and disk scheduling


  • Number of required bus cycles can be cut by integrating the DMA and I/O functions

  • Path between DMA module and I/O module that does not include the system bus

Chapter 4 device management and disk scheduling


Chapter 4 device management and disk scheduling


Chapter 4 device management and disk scheduling


4 3 operating system design issues

4.3 Operating System Design Issues

  • Efficiency

    • Most I/O devices extremely slow compared to main memory

    • Use of multiprogramming allows for some processes to be waiting on I/O while another process executes

    • I/O cannot keep up with processor speed

    • Swapping is used to bring in additional ready processes which is an I/O operation

    • Thus, a major effort in I/O design has been schemes for improving the efficiency of I/O. e.g. disk I/O

Operating system design issues

Operating System Design Issues

  • Generality

    • Desirable to handle all I/O devices in a uniform manner

    • Hide most of the details of device I/O in lower-level routines so that processes and upper levels see devices in general terms such as read, write, open, close, lock, unlock

Chapter 4 device management and disk scheduling

Struct general_op{

int (*read)(…)

int (*write)(…)



Struct general_op dev_op={ dev1_read,




Struct general_op dev_op={ dev2_read,







Logical structure of the i o function e g hierarchical p458

Logical Structure of the I/O Function (e.g. Hierarchical p458)

  • Logical I/O

    • Is concerned with general I/O function, and is not concerned with the detail of actually controlling. E.g. read, write…

  • Device I/O

    • Implement I/O instructions, channel commands, and controller orders. May use buffering techniques.

Logical structure of the i o function

Logical Structure of the I/O Function

  • Scheduling and Control

    • This is the level of software that actually interacts with the I/O module and the device hardware.

4 4 i o buffering p460

4.4I/O Buffering(p460)

  • Reasons for buffering

    • Processes must wait for I/O to complete before next proceeding. E.g: write to device (busy waiting or suspension on an interrupt)

    • Certain pages of the I/O request process must remain in main memory during I/O.

    • Single-process deadlock

I o buffering

I/O Buffering

  • Block-oriented

    • Information is stored in fixed sized blocks

    • Transfers are made a block at a time

    • Used for disks and tapes

  • Stream-oriented

    • Transfer information as a stream of bytes

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

Single buffer

Single Buffer

  • Operating system assigns a buffer in the system portion of main memory for an I/O request

  • Block-oriented

    • Input transfers made to buffer

    • Block moved to user space when needed

    • Another block is moved into the buffer

      • Read ahead

Single buffer1

Single Buffer

  • Block-oriented

    • User process can process one block of data while next block is read in

    • Swapping can occur since input is taking place in system memory, not user memory

    • Operating system keeps track of assignment of system buffers to user processes

Single buffer2

Single Buffer

  • Stream-oriented

    • Used a line at time.

    • User input from a terminal is one line at a time with carriage return signaling(回车信号) the end of the line.

    • Output to the terminal is one line at a time.

Single buffer3

Single Buffer

  • Performance comparison with no buffering

    • T: the time to input a block

    • C: the time to computation

    • M: the time to move data

    • Max [C,T]+M and T+C

Double buffer

Double Buffer

  • Use two system buffers instead of one.

  • A process can transfer data to or from one buffer while the operating system empties or fills the other buffer.

  • Performance: max(C,T).

Circular buffer

Circular Buffer

  • More than two buffers are used.

  • Each individual buffer is one unit in a circular buffer.

  • Used when I/O operation must keep up with process.

Disk and disk scheduling p463

Disk and Disk Scheduling(p463)

  • The speed of processors and main memory has far outstripped that for disk access.

  • The performance of disk storage subsystem is of vital concern.

  • How to improve the performance of disk?

    • General methods

    • Special methods

Disk structure

Disk Structure

  • Headers

  • Cylinders

  • Tracks

  • Sectors

  • Capability=headers*cylinders*sectors*byte per sector

Disk performance parameters

Disk Performance Parameters

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

  • Seek time

    • movable-head system or fixed-head system

    • Time it takes to position the head at the desired track

  • Rotational delay or rotational latency

    • Time its takes for the beginning of the sector to reach the head

Disk performance parameters1

Disk Performance Parameters

  • Data transfer time

  • Wait for device or channel

Rps rotational positional sensing

RPS (Rotational Positional Sensing)

  • When seek command has been issued, the channel is released to handle other I/O operations.

  • RPS miss. Must rotate again and reconnect again.

Seek time

Seek Time

Ts = m×n+s

n=number of tracks traversed

m=constant that depends on the disk drive

s=startup time

Rotational delay

Rotational Delay

Tr = 1/(2r)

r=rotation speed, in revolutions per second


r=3600rpm, Tr=1/120=8.3ms

r=300rpm, Tr=1/10=100ms

Transfer time

Transfer Time

T = b/(r×N)

b=number of bytes to be transferred

N=number of bytes on a track

r=rotation speed,in revolutions per second

Total average access time

Total Average Access Time


A timing comparison

A Timing Comparison

  • Seek time: 20ms

  • Transfer rate: 1MB/s

  • r=3600rpm

  • 512byte per sector

  • 32 sector per track

  • Suppose to read 128k data

A timing comparison1

A Timing Comparison

  • 60*16k=960k<1MB/s

  • Sequential organization


  • Randomly organization


A timing comparison2

A Timing Comparison

  • It is worthwhile to improve the I/O efficiency with purely random access to the disk

Disk scheduling policies

Disk Scheduling Policies

  • Seek time is the reason for differences in performance.

  • For a single disk there will be a number of I/O requests.

  • If requests are selected randomly, we will get the worst possible performance.

Disk scheduling policies1

Disk Scheduling Policies

  • First-in, first-out (FIFO)

    • Process request sequentially.

    • Fair to all processes.

    • Approaches random scheduling in performance if there are many processes.

Disk scheduling policies2

Disk Scheduling Policies

  • Priority

    • Goal is not to optimize disk use but to meet other objectives.

    • Short batch jobs may have higher priority.

    • Provide good interactive response time.

Fifo starting at track 100

FIFO (Starting at Track 100)


Disk scheduling policies3

Disk Scheduling Policies

  • Last-in, first-out

    • The device is given to the most recent user so there should be little arm movement

    • Possibility of starvation since a job may never regain the head of the line

Disk scheduling policies4

Disk Scheduling Policies

  • Shortest Service Time First

    • Select the disk I/O request that requires the least movement of the disk arm from its current position

    • Always choose the minimum seek time

55 58 39 18 90 160 150 38 184



Disk scheduling policies5

Disk Scheduling Policies

  • SCAN

    • Arm moves in one direction only, satisfying all outstanding requests until it reaches the last track in that direction

    • Direction is reversed

    • Max delay:2T. T: a scan time from inner track to outer track

Chapter 4 device management and disk scheduling



Disk scheduling policies6

Disk Scheduling Policies

  • C-SCAN

    • Restricts scanning to one direction only

    • When the last track has been visited in one direction, the arm is returned to the opposite end of the disk and the scan begins again

    • Max delay: T+Smax. Smax is the maximum seek time




Disk scheduling policies7

Disk Scheduling Policies

  • N-step-SCAN

    • Segments the disk request queue into subqueues of length N.

    • Subqueues are process one at a time, using SCAN.

    • New requests added to other queue when queue is processed.


    • Two queues

    • One queue is empty for new request

Figure 11 7 p469

Figure 11.7 P469

Raid p471


  • Redundant Array of Inexpensive Disks

  • Redundant Array of Independent Disks

Chapter 4 device management and disk scheduling


  • Using multiple disks can:

    • I/O requests can be handled in parallel.

    • The reliability of disk can be improved.

Raid characteristics

RAID Characteristics

  • RAID is a set of physical disk drives viewed by the operating system as a single logical drive. (transparent)

  • Data are distributed across the physical drives of an array.(distributed)

  • Redundant disk capacity is used to store parity information, which guarantees data recoverability in case of disk failure.(reliability)

Strip unit

Strip Unit(条化单元)

  • Data are striped across the available disks. (fig 11.9)The strips are mapped round robin to consecutive array members.

  • Small strip:

    • Parallel Access Technique

  • Large strip:

    • Independent Access Technique

Verify methods

Verify Methods

  • Mirror storage

  • Hamming code(distance =n)

  • Parity verify (distance =2)

    • X4(i)=X3(i)+X2(i)+X1(i)+X0(i)

    • X1(i)= X4(i)+X3(i)+X2(i)+X0(i)

    • Distribute or centralize storage

Raid characteristics1

RAID Characteristics

  • Strip unit and storage method

  • Verify method and storage method

Raid 0 non redundant

RAID 0 (non-redundant)

Raid 0


Raid 01


  • non-redundant

  • non-verify

  • distributed storage

  • Lower reliability

  • Lower cost

  • Parallel I/O access

Raid 1 mirrored

RAID 1 (Mirrored)

  • Distributed

  • Mirrored/redundancy

  • No verify

Raid 1


  • Read performance is better than RAID 0 (choose the seek time fewer disk to access)

  • Write performance is worse than RAID 0

  • Higher cost

  • Recovery is simple

  • It can have higher parallel performance than RAID0

Raid 2 redundancy through hamming code

RAID 2 (Redundancy Through Hamming Code)

Raid 2


  • Strips are very small, as a single byte or word.

  • Hamming code in special disks

  • Lower cost than RAID1 but higher than RAID3, 4,5

Raid 3 bit interleaved parity

RAID 3 (Bit-Interleaved Parity)

  • Same as RAID2 but use parity verify,so it only need a single redundant disk

Raid 3 performance

RAID 3—Performance

  • Small strip bringParallel Access Technique but only one I/O request can be executed at a time.

  • Lower cost than RAID2.

Raid 4 block level parity

RAID 4 (Block-Level Parity)

Raid 4


  • Large strip

  • Parity verify and storage into a special disk

  • Parity disk become a bottleneck

Raid 5 block level distributed parity

RAID 5 (Block-Level Distributed Parity)

Raid 5


  • Same as RAID4 but parity information distributed

  • Avoid bottleneck found in RAID Level 4

Disk cache p479

Disk Cache(p479)

  • Buffer in main memory for disk sectors.

  • Contains a copy of some of the sectors on the disk.

  • According to locality principle to cache .

Using methods

Using Methods

  • From disk-cache copy to user process space.

  • Using a shared memory capability and passing a pointer to the appropriate slot in the disk cache.

Least recently used i

Least Recently Used (I)

  • The block that has been in the cache the longest with no reference to it is replaced.

  • The cache consists of a stack of blocks.

  • Most recently referenced block is on the top of the stack.

  • When a block is referenced or brought into the cache, it is placed on the top of the stack.

Least recently used i1

Least Recently Used (I)

  • The block on the bottom of the stack is removed when a new block is brought in.

  • Blocks don’t actually move around in main memory.

  • A stack of pointers is used.

Least frequently used ii

Least Frequently Used (II)

  • The block that has experienced the fewest references is replaced.

  • A counter is associated with each block.

  • Counter is incremented each time block accessed.

  • Block with smallest count is selected for replacement.

  • Some blocks may be referenced many times in a short period of time and then not needed any more.

Integrate methods 1

Integrate Methods(1)

Integrate methods 11

Integrate Methods(1)

  • A area in new section , the count not add.

  • A area whose count is the least in old section will be replaced.

  • The count remains at 1 as long as the block remains in the new section

Integrate methods 2

Integrate Methods(2)

Integrate methods 21

Integrate Methods(2)

  • The count in middle section can add , but not replace the area in this section

Appendix 11a p492

Appendix 11a p492

  • Disk storage devices

  • Login