Module 5.0: I/O and Disks - PowerPoint PPT Presentation

About This Presentation
Title:

Module 5.0: I/O and Disks

Description:

Rotation/latency delay wait time for desired data to spin under r/w head ... Arm only goes as far as the last request in each direction, then reverses ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 32
Provided by: marily237
Category:

less

Transcript and Presenter's Notes

Title: Module 5.0: I/O and Disks


1
Module 5.0 I/O and Disks
  • I/O hardware
  • Polling and Interrupt-driven I/O
  • DMA
  • Bock and character devices
  • Blocking and nonblocking I/O
  • Secondary storage
  • Disk Hardware
  • Disk Scheduling
  • RAID

2
I/O Hardware
  • Incredible variety of I/O devices
  • Common concepts
  • Port serial, parallel, usb
  • Bus (daisy chain or shared direct access)
  • PCI bus, IDE Bus
  • SCSI (up to 16 devices)
  • Controller (host adapter)
  • I/O instructions control devices
  • Devices have addresses, used by
  • Direct I/O instructions
  • Memory-mapped I/O

3
A Typical PC Bus Structure
4
(No Transcript)
5
Polling vs. Interrupt-driven I/O
  • Polling or (Programmed I/O)
  • Determines state of device
  • command-ready
  • busy
  • error
  • Busy-wait cycle to wait for I/O from device
  • Interrupt-driven
  • (covered earlier)

6
Interrupt-driven I/O Cycle
7
Direct Memory Access
  • Used to avoid programmed I/O (or polling) for
    large data movement
  • Requires DMA controller
  • Bypasses CPU to transfer data directly between
    I/O device and memory

8
Application I/O Interface
  • I/O system calls encapsulate device behaviors in
    generic classes
  • Device-driver layer hides differences among I/O
    controllers from kernel
  • Devices vary in many dimensions
  • Character-stream or block
  • Sequential or random-access
  • Sharable or dedicated
  • Speed of operation
  • read-write, read only, or write only

9
A Kernel I/O Structure
ATAPI Advanced Technology Attachment Packet
Interface (for mass storage devices) SCSI Small
Computer Standard Interface
10
Block and Character Devices
  • Block devices include disk drives
  • Information is stored in fixed-size blocks, each
    block with its own address
  • Commands include read, write, seek
  • file-system access
  • Memory-mapped file access possible
  • Character devices include keyboards, mice, serial
    ports, printers
  • A stream of characters is sent or received
    without regard to any block structure
  • Commands include get, put
  • Other Devices
  • Varying enough from block and character to have
    own interface
  • E.g., Network devices, clocks, timers, etc.

11
Blocking and Nonblocking I/O
  • Blocking - process suspended until I/O completed
  • Easy to use and understand
  • Insufficient for some needs
  • Nonblocking - I/O call returns as much as
    available
  • User interface, data copy (buffered I/O)
  • Extremely useful and popular with ULTs
  • Does not block a ULT, and thus does not prevent
    other ULTS from running
  • Returns quickly with count of bytes read or
    written
  • Example search in Mozilla FireFox
  • Asynchronous - process runs while I/O executes
  • Difficult to use
  • I/O subsystem signals process when I/O completed
  • Used in C

12
Secondary Storage
  • Secondary Storage is often arranged in a
    hierarchy transparent to the user with
    fast/expensive storage at the top and slow/cheap
    storage at the bottom.

13
Disk Definitions
Volume a single storage unit, e.g. CD,
diskette, tape, partition Tracks multiple
concentric circles containing data Sectors
subsection of a track Blocks subsection of a
sector created during formatting
(512-4096B) Cylinder all tracks of same
diameter in the disk pack Fixed heads one r/w
head per track Moveable heads one r/w head per
surface Access time seek time latency time
(15-60ms) block transfer time (1-2ms)
14
Disk Hardware
  • Seek time -- time to get r/w head to desired
    track
  • Rotation/latency delay wait time for desired
    data to spin under r/w head
  • Block transfer time time to read or write block
    of data

15
Disk Structure
  • Disk drives are addressed as large 1-dimensional
    arrays of logical blocks, where the logical block
    is the smallest unit of transfer.
  • The 1-dimensional array of logical blocks is
    mapped into the sectors of the disk sequentially.
  • Sector 0 is the first sector of the first track
    on the outermost cylinder.
  • Mapping proceeds in order through that track,
    then the rest of the tracks in that cylinder, and
    then through the rest of the cylinders from
    outermost to innermost. (assuming no
    interleaving).
  • Block interleaving is used to allow some time for
    the disk controller to transfer data to memory.
    The controller can not keep up with the
    continuous bit streams from the disk.

16
Disk Scheduling
  • The operating system is responsible for using
    hardware efficiently for the disk drives, this
    means having a fast access time and disk
    bandwidth.
  • Minimize seek time. The other two factors are
    fixed.
  • Reason for differences in performance
  • Seek time ? seek distance
  • Disk bandwidth is the total number of bytes
    transferred, divided by the total time between
    the first request for service and the completion
    of the last transfer.
  • The idea is to improve both access time and
    bandwidth by scheduling the servicing of the disk
    I/O in a good order.

17
Disk Scheduling (Cont.)
  • Several algorithms exist to schedule the
    servicing of disk I/O requests.
  • We illustrate them with a request queue (0-199).
  • 98, 183, 37, 122, 14, 124, 65, 67
  • Head pointer 53

18
FCFS
Illustration shows total head movement of 640
cylinders.
19
SSTF Shortest Seek Time First
  • Selects the request with the minimum seek time
    from the current head position.
  • SSTF scheduling is a form of SJF scheduling may
    cause starvation of some requests.
  • Illustration shows total head movement of 236
    cylinders.

20
SCAN
  • The disk arm starts at one end of the disk, and
    moves toward the other end, servicing requests
    until it gets to the other end of the disk, where
    the head movement is reversed and servicing
    continues.
  • Sometimes called the elevator algorithm.
  • Illustration shows total head movement of 208
    cylinders.

21
C-SCAN
  • Provides a more uniform wait time than SCAN.
  • The head moves from one end of the disk to the
    other. servicing requests as it goes. When it
    reaches the other end, however, it immediately
    returns to the beginning of the disk, without
    servicing any requests on the return trip.
  • Treats the cylinders as a circular list that
    wraps around from the last cylinder to the first
    one.

22
C-LOOK
  • Version of C-SCAN
  • Arm only goes as far as the last request in each
    direction, then reverses direction immediately,
    without first going all the way to the end of the
    disk.

23
Selecting a Disk-Scheduling Algorithm
  • SSTF is common and has a natural appeal
  • SCAN and C-SCAN perform better for systems that
    place a heavy load on the disk.
  • Performance depends on the number and types of
    requests.
  • Requests for disk service can be influenced by
    the file-allocation method.
  • The disk-scheduling algorithm should be written
    as a separate module of the operating system,
    allowing it to be replaced with a different
    algorithm if necessary.
  • Either SSTF or LOOK is a reasonable choice for
    the default algorithm.

24
Disk Management
  • Low-level formatting, or physical formatting
    Dividing a disk into sectors that the disk
    controller can read and write.
  • Each sector/block (256,512,1024) has header,
    trailer, data
  • Header contains sector number
  • Trailer contains ECC (Error-Correcting Code)
  • To use a disk to hold files, the operating system
    still needs to record its own data structures on
    the disk.
  • Partition the disk into one or more groups of
    cylinders.
  • Logical formatting or making a file system
  • Holds data structure for NTFS or FAT
  • Boot block initializes system.
  • The bootstrap is stored in ROM.
  • Bootstrap loader program.

25
Booting from a Disk in Windows 2000
26
Swap-Space Management
  • Swap-space Virtual memory uses disk space as an
    extension of main memory.
  • Swap-space can be carved out of the normal file
    system,or, more commonly, it can be in a separate
    disk partition.
  • Swap-space management
  • 4.3BSD allocates swap space when process starts
    holds text segment (the program) and data
    segment.
  • Kernel uses swap maps to track swap-space use.
  • Solaris 2 allocates swap space only when a page
    is forced out of physical memory, not when the
    virtual memory page is first created.

27
Disk Performance and Reliability
  • Technology to improving processor performance is
    higher than improving secondary storage.
  • Several improvements in disk-use techniques
    involve the use of multiple disks working
    cooperatively. RAID technology, Redundant Array
    of Independent Disks.
  • RAID schemes improve performance and improve the
    reliability of the storage system by storing
    redundant data.
  • Set of physical disk drives viewed by the OS as a
    single logical drive
  • Data is distributed across the physical drives of
    an array
  • Redundant disk capacity is used to store parity
    information
  • Seven RAID configuration levels (RAID level 0 to
    RAID level 6).

28
Data Mapping for RAID level 0
  • RAID 0 is non-redundant, the other 6 levels are.
  • Data is striped across available disks
  • High data transfer rate
  • Strips 0, 1, 2, and 3 can be accessed in parallel
  • High I/O request rate
  • Servicing multiple I/O requests in parallel,
    e.g., requests for strip 0 and strip 3 can be
    serviced simultaneously.

29
RAID level 1
  • Redundancy is achieved using mirroring
    (duplication of data on other disks.)
  • Expensive
  • A read can be serviced by either disks (the least
    access time)
  • A write requires updating two strips
  • Recovery is simple

30
RAID level 2
  • All member disks participate in the execution of
    every I/O request. (Gives high transfer rate but
    not I/O request rate).
  • Spindles and heads are all synchronized to the
    same position
  • Strips are very small, a single byte or a word
  • Redundancy is done through Hamming Code (able to
    correct single-bit error and detect double bit
    errors).
  • Requires smaller number of disks compared to RAID
    level 1
  • RAID level 3 requires only one extra disk. It
    uses parity checks.

31
RAID Levels
Write a Comment
User Comments (0)
About PowerShow.com