Unix Device Taxonomy - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Unix Device Taxonomy

Description:

... devices queue buf structure (buffer); character devices queues clist ... At stream bottom (device driver), device may drop messages if its buffer is full ... – PowerPoint PPT presentation

Number of Views:11
Avg rating:3.0/5.0
Slides: 11
Provided by: quy8
Category:
Tags: device | taxonomy | unix

less

Transcript and Presenter's Notes

Title: Unix Device Taxonomy


1
Unix Device Taxonomy
  • clock does not transfer data
  • Block addressable storage devices
  • Data moved in substantial size units
  • Blocks are cached
  • Character all else
  • Originally referred to true single character at a
    time devices (e.g., keyboards and serial lines)
  • Now, includes networks and raw (unstructured)
    interfaces

2
Unix Device Drivers
  • Device-dependent software
  • Handles device-specific operations plus generic
    functions like management of request queue and
    buffers
  • Handles both layers 3 4
  • Device-dependent commands
  • Interrupt handling
  • Single driver controls any number of copies of
    device

3
Unix Device Drivers
  • Driver split into 2 parts
  • Top half (device driver layer)
  • Called by API, so runs in context of caller
  • Interfaces with rest of Unix
  • Includes synchronous routines invoked by syscall
  • Maintains queue of I/O operations underway or to
    be performed
  • Block devices queue buf structure (buffer)
    character devices queues clist structure
  • Syscall runs through top half, then blocks the
    calling process (waiting for I/O to complete)

4
Unix Device Drivers
  • Driver split into 2 parts
  • Bottom half (interrupt handler layer)
  • Caused to run by interrupt system, so runs in
    kernel context
  • Directly interfaces with device
  • Includes asynchronous routines invoked by
    interrupt handler
  • Drains queue and unblocks top half when I/O
    operation is done
  • Note that top bottom halves both access the
    queue, so need synchronization method

5
Unix I/O
  • Devices mounted as special files
  • Block and character devices appear in file system
    name space
  • Advantages
  • File I/O and device I/O look same to applications
  • Devices can be protected in the same way as files
  • Only superuser can create devices
  • Inode stores class (block or character) and major
    and minor device numbers
  • Device driver located by class and major device
    number
  • Major indexes into array for that class (bdevsw
    for block device array cdevsw for character
    array) and identifies entry points for device
    driver
  • Minor passed to driver to identify specific
    device

6
Block Special Files
  • Goal is to minimize number of data transfers
  • Block device is buffered by block cache (or
    buffer)
  • Cache hit eliminates need for I/O operation
  • Cache flushed on command and periodically
    (usually every 30 secs.)
  • Sync flush whole cache
  • Fsync flush blocks of single file
  • Block devices often have a second, character
    interface for unbuffered I/O

7
Character Special Files
  • BSD and classic Unix use c-lists
  • Block of up to 64 characters
  • Characters from character devices (mouses,
    terminals) buffered into chain of c-lists
  • Line discipline
  • Process data in c-lists before transfer to
    process
  • 3 models
  • Raw no processing
  • Cbreak no line editting
  • Cooked character stream
  • Carriage returns mapped to line feeds
  • Tabs mapped to spaces
  • Remove erased characters

8
Character Special Files Streams
  • Motivations
  • Only one line discipline may be in use at a time
  • Network protocols naturally implemented as
    pipelines
  • Properties
  • Stream head module that connects to process and
    implements syscall (read, write, etc.)
  • Stream bottom device driver
  • Other stream modules may be dynamically
    inserted/removed in between head and bottom
  • Standard inter-module interface allows different
    programmers/vendors to write modules that work
    together
  • Analogous to pipes in user-space, but more
    powerful because data flows in 2 directions and
    numerous data flow controls

9
Character Special Files Streams
  • Data flow control capabilities
  • Call neighboring modules put routine to enqueue
    a message (containing data and/or control
    information)
  • Put is non-blocking if put-onto queue is full,
    caller puts message on its own outgoing queue
  • Asynchronous except at stream head where user
    process will block waiting for I/O to complete
  • At stream bottom (device driver), device may drop
    messages if its buffer is full
  • Each modules service routine is scheduled by OS
    - Service routine drains incoming from neighbors
    and tries to push along outgoing messages to
    neighbors
  • Each module maintains read/write queue to ensure
    correct order of processing
  • Messages may specify priorities and service may
    reorder message processing
  • Ability to multiplex modules can split or merge
    streams

10
Character Special Files Streams
  • Advantages
  • Provides modular and incremental framework for
    writing device drivers and network protocols
  • Modules may be used by different streams and by
    different devices
  • Example network modules used by different
    network protocols (ethernet vs. token ring)
  • Supports message boundaries through flow control
    unstructured byte stream can be converted into
    structured messages
  • System V, streams used for
  • Named pipes
  • Interprocess communication
  • Network protocols
  • Many character devices (e.g., terminals)
Write a Comment
User Comments (0)
About PowerShow.com