Ref: Chap 12 - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Ref: Chap 12

Description:

Ref: Chap 12 Secondary Storage and I/O Systems – PowerPoint PPT presentation

Number of Views:97
Avg rating:3.0/5.0
Slides: 36
Provided by: MarilynT78
Category:
Tags: alignment | chap | ref | shaft

less

Transcript and Presenter's Notes

Title: Ref: Chap 12


1
Ref Chap 12
  • Secondary Storage and I/O Systems

2
Part 1 - Secondary Storage
  • Secondary storage typically
  • is anything that is outside of primary memory
  • does not permit direct execution of instructions
    or data retrieval via machine load/store
    instructions
  • Characteristics
  • its large 30-60GB
  • its cheap 40GB 130.
  • 0.3 cents per megabyte (wow!)?
  • its persistent data survives power loss
  • its slow milliseconds to access
  • why is this slow??

3
(No Transcript)
4
Size and Access Time
5
Disks and the OS
  • Disks are messy devices
  • errors, bad blocks, missed seeks, etc.
  • Job of OS is to hide this mess from higher-level
    software
  • low-level device drivers (initiate a disk read,
    etc.)?
  • higher-level abstractions (files, databases,
    etc.)?
  • OS may provide different levels of disk access to
    different clients
  • physical disk block (surface, cylinder, sector)?
  • disk logical block (disk block )?
  • file logical (filename, block or record or byte
    )?

6
Physical Disk Structure
IBM Ultrastar 36XP drive form factor 3.5
capacity 36.4 GB rotation rate 7,200 RPM (120
RPS) platters 10 surfaces 20 sector size
512 to 732 bytes cylinders 11,494 cache
4MB transfer rate 17.9 MB/s (inner) 28.9
MB/s (outer) full seek 14.5 ms head switch
0.3 ms
7
Platter
8
Interacting with Disks
  • In the old days
  • OS would have to specify cylinder , sector ,
    surface , transfer size
  • I.e., OS needs to know all of the disk parameters
  • Modern disks are even more complicated
  • not all sectors are the same size, sectors are
    remapped,
  • disk provides a higher-level interface, e.g. SCSI
  • exports data as a logical array of blocks 0 N
  • maps logical blocks to cylinder/surface/sector
  • OS only needs to name logical block , disk maps
    this to cylinder/surface/sector
  • as a result, physical parameters are hidden from
    OS
  • both good and bad

9
Disk Performance
  • Performance depends on a number of steps
  • seek moving the disk arm to the correct cylinder
  • depends on how fast disk arm can move
  • seek times arent diminishing very quickly
  • rotation waiting for the sector to rotate under
    head
  • depends on rotation rate of disk
  • rates are increasing, but slowly
  • transfer transferring data from surface into
    disk controller, and from there sending it back
    to host
  • depends on density of bytes on disk
  • increasing, and very quickly
  • When the OS uses the disk, it tries to minimize
    the cost of all of these steps particularly seeks
    and rotation

10
Disk Scheduling (1)?
  • Seeks are very expensive, so the OS attempts to
    schedule disk requests that are queued waiting
    for the disk
  • FCFS (do nothing)?
  • reasonable when load is low
  • long waiting time for long request queues
  • requests served in order of arrival simplest
    and fairest policy works well when few
    processes, each accessing sectors that are
    clustered together poor when many processes
    compete for access to disk
  • SSTF (shortest seek time first)?
  • minimize arm movement (seek time), maximize
    request rate
  • unfairly favors middle blocks
  • scheduler needs to know current track position
    chooses request involving nearest track gt
    method for tie-breaking also needs to be adopted
    not optimal, but likely to be better than FIFO
    starvation problem

11
Disk Scheduling (2)?
  • SCAN (elevator algorithm)?
  • arm moves in one direction only until it reaches
    last track (or until no further requests in that
    direction, also known as LOOK), servicing
    requests as it goes reverses direction after
    each scan no starvation upon reversal,
    tracks with highest density of requests likely to
    be furthest away!
  • skews wait times non-uniformly
  • C-SCAN
  • like scan, but only go in one direction
    (typewriter)?
  • uniform wait times
  • arm flies back to beginning instead of reversing
    direction upon reaching last track or no further
    requests in that direction (C-LOOK)

12
Head Movement
  • Current position track 100
  • Requested tracks ( in order received)
  • 55, 58, 39, 18, 90, 160, 150, 38, 184
  • FIFO move 45 tracks to track 55 move 3 tracks
    to track 58 etc.
  • SSTF move 10 tracks to track 90 move 32 tracks
    to track 58 etc.
  • SCAN, C-SCAN (moving in direction of increasing
    track number) move 50 tracks to track 150 move
    10 tracks to track 160 etc.

13
New Hard-Drive Preparation
  • See notes on formatting hard-drives

14
Part 2 - I/O Subsystems
  • I/O hardware
  • Application I/O Interface
  • Kernel I/O Subsystem
  • Transforming I/O Requests to Hardware Operations
  • Performance

15
I/O Hardware
  • Incredible variety of I/O devices
  • Common concepts
  • Port
  • Bus (daisy chain or shared direct access)?
  • Controller (host adapter)?
  • I/O instructions control devices
  • Devices have addresses, used by
  • Direct I/O instructions
  • Memory-mapped I/O

16
Polling
  • Determines state of device
  • command-ready
  • busy
  • error
  • Busy-wait cycle to wait for I/O from device

17
Interrupts
  • CPU Interrupt request line triggered by I/O
    device
  • Interrupt handler receives interrupts
  • Maskable to ignore or delay some interrupts
  • Interrupt vector to dispatch interrupt to correct
    handler
  • Based on priority
  • Some unmaskable
  • Interrupt mechanism also used for exceptions

18
Interrupt-driven I/O Cycle
19
Direct Memory Access
  • Direct memory access (DMA) is a feature of modern
    computers that allows certain hardware subsystems
    within the computer to access system memory for
    reading and/or writing independently of the
    central processing unit
  • Used to avoid programmed I/O for large data
    movement
  • Requires DMA controller
  • Bypasses CPU to transfer data directly between
    I/O device and memory
  • Many hardware systems use DMA including disk
    drive controllers, graphics cards, network cards,
    and sound cards.
  • Computers that have DMA channels can transfer
    data to and from devices with much less CPU
    overhead than computers without a DMA channel.

20
DMA on ISA and PCI bus
  • A DMA transfer essentially copies a block of
    memory from one device to another.
  • While the CPU initiates the transfer, it does not
    execute it.
  • For so-called "third party" DMA, as is normally
    used with the ISA bus, the transfer is performed
    by a DMA controller which is typically part of
    the motherboard chipset.
  • More advanced bus designs such as PCI typically
    use bus mastering DMA, where the device takes
    control of the bus and performs the transfer
    itself
  • More precisely, a PCI component requests bus
    ownership from the PCI bus controller (usually
    the southbridge in a modern PC design), which
    will arbitrate if several devices request bus
    ownership simultaneously, since there can only be
    one bus master at one time.
  • When the component is granted ownership, it will
    issue normal read and write commands on the PCI
    bus, which will be claimed by the bus controller
    and forwarded to the memory controller using a
    scheme which is specific to every chipset..

21
Six step process to perform DMA transfer
22
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

23
Block and Character Devices
  • Block devices include disk drives
  • Commands include read, write, seek
  • Raw I/O or file-system access
  • Memory-mapped file access possible
  • Character devices include keyboards, mice, serial
    ports
  • Commands include get, put
  • Libraries layered on top allow line editing

24
Network Devices
  • Varying enough from block and character to have
    own interface
  • Unix and Windows/NT include socket interface
  • Separates network protocol from network operation
  • Includes select functionality
  • Approaches vary widely (pipes, FIFOs, streams,
    queues, mailboxes)?

25
Clocks and Timers
  • Provide current time, elapsed time, timer
  • if programmable interval time used for timings,
    periodic interrupts
  • ioctl (on UNIX) covers odd aspects of I/O such as
    clocks and timers

26
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)?
  • Implemented via multi-threading
  • Returns quickly with count of bytes read or
    written
  • Asynchronous - process runs while I/O executes
  • Difficult to use
  • I/O subsystem signals process when I/O completed

27
Kernel I/O Subsystem
  • Scheduling
  • Some I/O request ordering via per-device queue
  • Some OSs try fairness
  • Buffering - store data in memory while
    transferring between devices
  • To cope with device speed mismatch
  • To cope with device transfer size mismatch
  • To maintain copy semantics

28
Kernel I/O Subsystem
  • Caching - fast memory holding copy of data
  • Always just a copy
  • Key to performance
  • Spooling - hold output for a device
  • If device can serve only one request at a time
  • i.e., Printing
  • Device reservation - provides exclusive access to
    a device
  • System calls for allocation and deallocation
  • Watch out for deadlock

29
Error Handling
  • OS can recover from disk read, device
    unavailable, transient write failures
  • Most return an error number or code when I/O
    request fails
  • System error logs hold problem reports

30
Kernel Data Structures
  • Kernel keeps state info for I/O components,
    including open file tables, network connections,
    character device state
  • Many, many complex data structures to track
    buffers, memory allocation, dirty blocks
  • Some use object-oriented methods and message
    passing to implement I/O

31
I/O Requests to Hardware Operations
  • Consider reading a file from disk for a process
  • Determine device holding file
  • Translate name to device representation
  • Physically read data from disk into buffer
  • Make data available to requesting process
  • Return control to process

32
Life Cycle of an I/O Request
33
Performance
  • I/O a major factor in system performance
  • Demands CPU to execute device driver, kernel I/O
    code
  • Context switches due to interrupts
  • Data copying
  • Network traffic especially stressful

34
Intercomputer communications
35
Improving Performance
  • Reduce number of context switches
  • Reduce data copying
  • Reduce interrupts by using large transfers, smart
    controllers, polling
  • Use DMA
  • Balance CPU, memory, bus, and I/O performance for
    highest throughput
Write a Comment
User Comments (0)
About PowerShow.com