13 IO Systems - PowerPoint PPT Presentation

1 / 46
About This Presentation
Title:

13 IO Systems

Description:

I/O subsystem separates the rest of the kernel from the ... offload work to a DMA controller for large data transfer. 19. 13.3 Application I/O Interface ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 47
Provided by: zjt8
Category:
Tags: offload | systems

less

Transcript and Presenter's Notes

Title: 13 IO Systems


1
13 I/O Systems
2
Contents
  • I/O Hardware
  • Application I/O Interface
  • Kernel I/O Subsystem
  • Transforming I/O Requests toHardware Operations
  • STREAMS
  • Performance

3
13.1 Overview
  • main jobs of a computer I/O and processing
  • I/O subsystem separates the rest of the kernel
    from the complexity of managing I/O devices
  • an increasing standardization of software and
    hardware interfaces
  • an increasingly broad variety of I/O devices
  • device drivers present a uniform device access
    interface to the I/O subsystem

4
13.2 I/O Hardware
  • incredible variety of I/O devices
  • character versus block
  • sequential access, random access
  • synchronous, asynchronous
  • dedicated, shared
  • read-only, read-write
  • very slow to very fast

5
Functional categories
  • storage devices
  • disks, tapes, CD-ROMs
  • transmission devices
  • network cards, modems
  • human-interface devices
  • screen, keyboard, mouse

6
Common Concepts
  • port a device communicates with the machine via
    a connection point, e.g. a serial port
  • bus a set of wires and a protocol
  • daisy chain (e.g. SCSI)
  • shared direct access (e.g. PCI bus)
  • controller a collection of electronics that
    operate a port, a bus, or a device
  • a serial-port controller
  • a SCSI bus controller (also called host adapter)
  • built-in controller (e.g. disk controller)

7
A Typical PC Bus Structure
8
interface registers
  • the processor communicates with the controller by
    reading and writing bit patterns in data and
    control registers
  • an I/O port typicaly consists of four kind of
    registers
  • status register
  • control register
  • data-in register(s)
  • data-out register(s)

9
I/O instruction memory-mapped I/O
  • I/O instructions control devices
  • controllers registers have addresses, used by
  • direct I/O instructions
  • memory-mapped I/O
  • some system use both techniques
  • e.g. the graphic controller in a PC system, I/O
    registers content memory

10
Device I/O Port Locations on PCs
11
13.2.1 Polling
  • determines state of device
  • command-ready
  • busy
  • error
  • busy-wait cycle to wait for I/O from device
  • low efficiency in processor usage

12
13.2.2 Interrupts
  • CPU interrupt request line triggered by I/O
    device
  • two lines nonmaskable and maskable
  • interrupt handler receives interrupts
  • interrupt mask to ignore or delay some interrupts
  • some unmaskable
  • interrupt vector to dispatch interrupt to correct
    handler
  • based on priority
  • interrupt mechanism also used for exceptions

13
Interrupt-Driven I/O Cycle
14
Intel Pentium ProcessorEvent-Vector Table
15
more about interrupt
  • software interrupt, system call, trap
  • two part of handler (or a pair of handlers)
  • top-half and bottom-half in Linux
  • p.61-71 in lab book
  • e.g. a series of block read from disk, and copy
    from kernel space to user space

16
13.2.3 Direct Memory Access
  • used to avoid programmed I/O for large data
    movement
  • e.g. a disk drive does a large data transfer
  • requires DMA controller
  • a special-purpose processor
  • bypasses CPU to transfer data directly between
    I/O device and memory
  • handshake between the main processor and the DMA
    controller two wires
  • DMA-request wire
  • DMA-acknowledge wire

17
Six Step Process to PerformDMA Transfer
18
section review
  • a bus
  • a controller
  • an I/O port and its registers
  • handshake between host and controller
  • execution of handshake via polling or interrupts
  • offload work to a DMA controller for large data
    transfer

19
13.3 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

20
A Kernel I/O Structure
21
Characteristics of I/O Devices
22
13.3.1 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

23
13.3.2 Network Devices
  • varying enough from block and character to have
    own interface
  • Unix and Windows NT/95/98/2000 include socket
    interface
  • separates network protocol from network operation
  • includes select functionality
  • approaches vary widely
  • half-duplex pipes, full-duplex FIFOs, full-duplex
    STREAMS, message queues, mailboxes

24
13.3.3 Clocks and Timers
  • provide current time, elapsed time, timer to
    trigger some operation
  • programmable interval timer (a hardware) can be
    set to generate periodic interrupts
  • process scheduling
  • disk synchronization (flush dirty buffers)
  • ioctl (on UNIX) covers odd aspects of I/O such as
    clocks and timers

25
13.3.4 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 program and use
  • I/O subsystem signals process when I/O completed

26
13.4 Kernel I/O Subsystem
  • scheduling
  • buffering
  • spooling
  • device reservation
  • error handling

27
13.4.1 Scheduling
  • scheduling a set of I/O requests means to
    determine a good order in which to execute them
  • the order in which applications issue system
    calls is usually not optimal
  • scheduling improve fairness, reduce the average
    waiting time for I/O
  • example disk arm move
  • a queue of request for each device
  • optimization for overall system performance
    (throughput)
  • some OSs try fairness

28
13.4.2 Buffering
  • store data in memory while transferring between
    devices or between a device and an application
  • to cope with device speed mismatch
  • to cope with device transfer size mismatch
  • fragmentation and reassembly (in network)
  • to maintain copy semantics
  • an additional kernel buffer to safeguard
    occasional data change in user space

29
Device Speed Mismatch
Sun Enterprise 6000 Device-Transfer Rates
30
14.4.3 Caching
  • caching - fast memory holding copy of data
  • always hold just a copy
  • key to performance
  • buffer versus cache
  • buffer may hold the only copy of the data
  • cache holds a copy on faster storage of an item
    that resides elsewhere

31
14.4.4 Spooling and Device Reservation
  • spooling - hold output for a device
  • if device can serve only one request at a time
  • i.e., printer
  • device reservation - provides explicit facilities
    for exclusive access to a device
  • system calls for allocation and deallocation
  • watch out for deadlock

32
14.3.5 Error Handling
  • OS can recover from transient devices and I/O
    transfer errors
  • device unavailable, transient read or write
    failures, network overload
  • most return an error number or error code when
    I/O request fails
  • system error logs hold problem reports

33
13.4.6 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
  • e.g. Windows NT

34
UNIX I/O Kernel Structure
35
I/O subsystem summary
  • management of name of files and devices
  • access control to files and devices
  • file system space allocation
  • device allocation (including reservation)
  • buffering, caching, spooling
  • I/O scheduling
  • device status monitoring, error handling
  • device driver configuration

36
13.5 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
  • 10 steps in detail on p. 479-481

37
Life Cycle of an I/O Request
38
13.6 STREAMS
  • STREAM a full-duplex communication channel
    between a user-level process and a device
  • a STREAM consists of
  • - stream head interfaces with the user process
  • - driver end interfaces with the device- zero
    or more stream modules between them.
  • each module contains a read queue and a write
    queue
  • message passing is used to communicate between
    queues

39
The STREAMS Structure
40
13.7 Performance
  • I/O is a major factor in system performance
  • demands CPU to execute device driver, kernel I/O
    code
  • context switches due to block and unblock
  • interrupt handling
  • data copying
  • network traffic especially stressful

41
Intercomputer Communications
example telnet
42
Improving Performance
  • reduce number of context switches
  • reduce data copying
  • reduce interrupts by using large transfers, smart
    controllers, polling (PIO)
  • use DMA
  • use hardware implementation
  • balance CPU, memory, bus, and I/O performance for
    highest throughput

43
Device-Functionality Progression
44
13.8 Summary
  • hardware
  • buses
  • device controllers
  • devices
  • programmed I/O, and DMA
  • system calls
  • blocking, or synchronous
  • nonblocking, or asynchronous

45
Summary
  • kernels I/O subsystem
  • I/O scheduling, buffering, spooling, error
    handling, device reservation
  • name translation
  • I/O system calls are costly
  • CPU consumption, context switch, interrupt
    handling, data copy

46
Homework
  • paper
  • 2, 3, 4
  • oral
  • 6, 7
Write a Comment
User Comments (0)
About PowerShow.com