InputOutput - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

InputOutput

Description:

USB. Mouse. Key. board. 3. I/O Subsystem. I/O Subsystem Functions. Provide OS-Device Interaction ... a standard interface that all block device drivers must support ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 17
Provided by: larry310
Category:

less

Transcript and Presenter's Notes

Title: InputOutput


1
Input/Output
  • Two main jobs of a computer are
  • Processing
  • Compute an answer matrix multiplication, FFT
  • ? OS must control the central processing unit,
    the CPU
  • Process management (creation/termination),
    process scheduling, process synchronization,
    memory management
  • Input/Output (I/O)
  • Get user input from the keyboard -- Keyboard
  • Display the chars that the user types on the
    screen -- Display
  • Read/Save a file from/to the disk Floppy, hard
    disk, CD-ROM
  • Download a Web page using the Web Browser
    Network Card (NIC)
  • ? OS must control all I/O devices
  • Done by the I/O subsystem of the OS

2
Typical PC Arch. OS Kernel Struc.
3
I/O Subsystem
  • I/O Subsystem Functions
  • Provide OS-Device Interaction
  • Issue commands to the devices, catch interrupts,
    handle errors
  • Provide OS-Application Process Interaction
  • Export an easy-to-use API to the applications
  • Open, read, write, close

4
I/O Subsystem
  • I/O Subsystem can roughly be divided into 2
    layers
  • A device dependent part, called the device
    driver, which implements the OS-device
    interaction part
  • A device independent part, which implements the
    OS-User Application Process interaction part

5
I/O Subsystem
  • Device drivers implement the OS-device
    interaction
  • Interacts with the device controller using the
    controller interface (Hardware Controller API)
  • Exports an interface to the Device Independent
    Software Layer above it (Device Driver API)

6
Device Drivers (more)
  • Interacting with the device controller
    Controller API
  • Driver knows the specifics of the device
  • What registers does the device controller have?
  • How to program these control registers and access
    data registers etc.
  • Driver interacts with the device controller to
    perform I/O
  • Issue commands to the controller to perform I/O
  • Catch device interrupts
  • Handle I/O device errors

7
Device Independent Software
  • Sits on top of the device drivers
  • Uses the device driver API to perform actual I/O
  • Exports a system-call API for application
    processes to perform I/O from the user space

8
Device Driver API
  • Interacting with the Device Independent Software
    layer Device Driver API
  • Lots of I/O devices!
  • We can define an interface for each type of
    device?
  • Too many interfaces.
  • Solution Classify I/O devices into one of a
    small number of categories and define an
    interface for each group.
  • Block devices - Disks
  • Those that store info in fixed sized blocks, each
    with its own address.
  • It is possible to read/write each block
    independently of each other
  • Character devices - keyboards, printers, NIC,
    mouse,
  • Those that deliver or accept a stream of chars
    without regard to any block structure.
  • Not addressable and does not have a seek operation

9
Device Driver API
  • Most OSs define
  • a standard interface that all block device
    drivers must support
  • a standard interface that all character device
    drivers must support
  • These interfaces consists of a number of
    functions that the rest of the OS can call to get
    the driver to do work for it
  • Read a block, write a char etc.
  • A standard interface that all network device
    drivers must support
  • Transmit a packet, receive a packet
  • Since each OS defines its own device driver API,
    a new device driver must be implemented for each
    OS

10
I/O System Call API -- Issues
  • Device Naming/Protection How does an
    application name an I/O device such as a disk or
    keyboard?
  • Assign symbolic names for each device and have
    DIS to map symbolic names onto proper driver
  • /dev/disk0, /dev/tty0 Unix, Linux (part of the
    file system)
  • C, D, COM1 -- Windows (separate name space)
  • Symbolic names uniquely identify the device
    within the OS
  • /dev/disk0 uniquely specifies the inode for a
    special file, and this inode contains the major
    device, which is used to locate the appropriate
    driver.
  • The inode also contains the minor device , which
    is passed as a parameter to the driver in order
    to specify the unit to be read/written
  • Setting access rights to different users?
  • Simply set the appropriate file protection
    rights -- Unix

11
I/O System Call API -- Issues
  • I/O Call Semantics
  • Blocking (Synchronous) I/O Calls
  • process suspended until I/O completed
  • Easy to use and understand
  • Insufficient for some needs
  • E.g., if the process is single threaded
  • Non-Blocking (Asynchronous) I/O Calls
  • process runs while I/O executes
  • Difficult to use
  • I/O subsystem signals process when I/O completed

12
DIS Services
  • Scheduling
  • Some I/O request ordering via per-device queue
  • Disk I/O (read/write) scheduling later
  • Buffering - store data in memory while
    transferring between devices
  • E.g., Network packets arriving for a process
    asynchronously
  • Caching - fast memory holding copy of data
  • Key to performance Keep the recently accessed
    disk blocks for faster read/write operations
    called the disk I/O cache

13
DIS Services
  • Keeping Track of User Process I/O State
  • Kernel keeps state info for processes, including
    open file tables, network connections, character
    device state

14
User-level I/O Software
  • Typically a user-level I/O library is first used
    by the application programs. Its functions are
  • Format I/O printf, fprintf, fopen,
  • Buffering May also buffer data before making
    system calls to improve performance

15
Input/Output Summary
  • Handling of an I/O requests and list of each
    layer with their functionality

16
Layers of I/O Subsystem in Linux
Process 2
Process 1
Process N
User Mode
Kernel Mode
Virtual File System
ext2fs
ntfs
fat32
proc
Buffer Cache
File System
Device Drivers
Write a Comment
User Comments (0)
About PowerShow.com