Input and Output - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Input and Output

Description:

A special kind of Device. The Graphical User Interface. aka, the bitmapped display ... Dog. CS-3013 & CS-502, Summer 2006. Input / Output. 22. GUI Device Color ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 29
Provided by: hughc7
Category:
Tags: dog | get | input | kind | of | output | should | what

less

Transcript and Presenter's Notes

Title: Input and Output


1
Input and Output
  • CS-3013 CS502Operating SystemsSummer 2006

2
Review
  • Demand paging performance metrics
  • EAT Effective access time
  • Faster computers require bigger working sets
  • TLB example
  • VM Page replacement strategies
  • Name some
  • Swap-in strategies
  • Discuss

3
Review (continued)
  • Segmentation
  • A program-visible way to increase VM size
  • Kernel memory
  • What is so special about this?
  • I/O devices
  • Make or break issue for any system
  • Largest portion of code of OS
  • Most likely area for OS engineer to work in

4
Review (continued)
  • Types of devices
  • Character, block, graphical, clocks other
  • Controlling a device
  • Programmed I/O, Interrupt-driven, DMA

5
Outline for this evening
  • I/O continued device drivers
  • Network I/O
  • Programming Project 3
  • Disks

6
Device Drivers
  • Organization
  • Static or dynamic
  • Uniform interfaces to OS
  • Uniform buffering strategies
  • Hide device idiosyncrasies

7
Device Drivers
  • Device Drivers are dependent on both the OS
    device
  • OS dependence
  • Meet the interface specs of the device
    independent layer
  • Utilize the facilities supplied by OS buffers,
    error codes, etc.
  • Accept and execute OS commands e.g. read, open,
    etc.
  • Device Dependent
  • Actions during Interrupt Service routine
  • Translate OS commands into device operations
  • E.g read block n becomes a series of setting and
    clearing and interpreting device registers or
    interfaces
  • Note that some device drivers have layers
  • Strategy or policy part to optimize arm movement
    or do retries plus a mechanism part the executes
    the operations

8
OS Responsibility to Device Driver
  • Uniform API
  • Open, Close, Read, Write, Seek functions
  • ioctl function as escape mechanism
  • Buffering
  • Kernel functions for allocating, freeing,
    mapping, pinning buffers
  • Uniform naming
  • /dev/(type)(unit)
  • type defines driver unit says which device
  • Other
  • Assign interrupt level (IRQ)
  • Protection (accessibility by application,
    user-space routines)
  • Error reporting mechanism

9
Uniform API and Buffering ExampleMemory-mapped
Keyboard
  • /dev/kb
  • Device interrupt routine detects key transitions
  • Driver converts sequence of transitions into
    characters in users written language
  • Characters placed sequentially in buffer
  • Accessible by read()
  • Application calls getchar() or get()
  • Library routines implemented with read()
  • Provides uniform input stream semantics

10
Buffering
  • DMA devices need memory to read from, write to
  • Must be contiguous pages
  • (Usually) physical addresses
  • Double buffering
  • One being filled (or emptied) by device
  • Other being emptied (or filled) by application
  • Special case of producer-consumer with n 2

11
Installing Device Drivers
  • Classic Unix
  • Create and compile driver to .o file
  • Edit and re-compile device table to add new
    device
  • Re-link with .o files for OS kernel ? new boot
    file
  • Classic MacIntosh
  • Submit to Apple for verification, approval, and
    inclusion
  • MS-DOS and Windows
  • Dynamic driver loading and installation
  • Special driver-level debuggers available
  • Open device environment
  • Certification program for trademarking
  • Linux
  • Originally static now dynamic

12
Dynamic Device Configuration
  • At boot time
  • Probe hardware for inventory of devices
    addresses
  • Map devices to drivers (using table previously
    created)
  • Load necessary drivers into kernel space,
    register in interrupt vector (.sys files in
    Windows)
  • Run time
  • Detect interrupt from newly added device
  • Search for driver, or ask user add to table
  • Load into kernel space, register in interrupt
    vector

13
Probing for devices
  • (Most) bridge and bus standards include
    registration protocol
  • vendor, device ID
  • OS (recursively) tests every addressable
    connection
  • If device is present, it responds with own ID
  • Performed both at
  • Boot time to associate drivers with addresses
  • Installation time to build up association table

14
Alternative Self-registration
  • In systems where every module or class
    initializes itself
  • At start-up time, each driver module is invoked
  • Checks for presence if device
  • If present, registers with OS its
  • Name
  • Interrupt handler
  • Shutdown action
  • Hibernate action
  • Sleep action

15
Allocating and Releasing Devices
  • Some devices can only be used by one application
    at a time
  • CD-ROM recorders
  • GUI interface
  • Allocated at Open() time
  • Freed at Close() time

16
User Space I/O Software(Daemons and Spoolers)
  • Device registers mapped into daemon VM
  • Controlled directly by daemon
  • Lower-half service routine
  • Handles interrupts
  • Signals via semaphores or monitors
  • Upper-half service routine
  • The daemon itself!
  • Waits for signals or monitors
  • Manages device and requests from outside kernel

17
User Space I/O examplePrint Spooler
  • /dev/lpt is a virtual device available to every
    process user
  • Driver causes
  • Printing to spool file
  • Control info to spooler daemon
  • Printer selection, options, and parameters
  • Spooler selects one print job at a time
  • Prints from spool file to physical device
  • Types of printing
  • Simple character strings separated by \n
    characters
  • Stream of PCL or inkjet commands
  • Postscript file

18
Character Terminal
  • Really two devices
  • Keyboard input
  • Character display output
  • /dev/tty (Unix) or COM (Windows)
  • The classic input-output terminal
  • RS-232 standard
  • Modes
  • raw
  • cooked (aka canonical) with backspace
    correction, tab expansion, etc.
  • Printed output vs. CRT display

19
A special kind of DeviceThe Graphical User
Interface
  • aka, the bitmapped display
  • In IBM language all points addressable
  • 300K pixels to 2M pixels
  • Each pixel may be separated written
  • Collectively, they create
  • Windows
  • Graphics
  • Images
  • Videos
  • Games

20
GUI Device early days
  • Bitmap in main memory
  • All output via library routines to bitmap
  • Entirely (or mostly) in user space
  • Controller, an automaton to do
  • D-A conversion (digital to analog video)
  • 60 Hz refresh rate
  • clock interrupt at top of each frame

CPU
Main Memory
Video
Bitmap
Digital toAnalog
21
GUI Device Displaying Text
  • Font an array of bitmaps, one per character
  • Designed to be pleasing to eye
  • bitblt (Bit-oriented Block Transfer)
  • An operation to copy a rectangular array of
    pixels from one bitmap to another


Bitmap
A
B
C
D
E
F
Dog
bitblt
22
GUI Device Color
  • Monochrome one bit per pixel
  • foreground vs. background
  • Color 2-32 bits per pixel
  • Direct vs. Color palette
  • Direct (usually) 8 bits each per Red, Green,
    Blue
  • Palette a table of length 2p, for p-bit pixels
  • Each entry (usually) 8 bits each for RGB

23
GUI Device Cursor
  • A small bitmap to overlay main bitmap
  • Hardware support
  • Substitute cursor bits during each frame
  • Software implementation
  • Bitblt area under cursor to temporary bitmap
  • Bitblt cursor bitmap to main bitmap
  • Restore area under cursor from temporary bitmap
  • Very, very tricky!
  • Timing is critical for smooth appearance
  • Best with double-buffered main bitmap

24
GUI Device Window
  • A virtual bitmap
  • size, position, clipping boundaries
  • font, foreground and background colors
  • A list of operations needed to redraw contents
  • Operations to window itself
  • write(), refresh()

Called by application to add/change information
Called by window manager to redraw current
contents
25
GUI Device Text Window
  • Character terminal emulated in a window
  • RS-232 character set and controls
  • /dev/tty
  • Operates like a character terminal with visible,
    partially obscured, or completely covered

26
Modern GUI Devices
Main Memory
AGP Port
CPU
Level 2 cache
Bridge
Graphics card
Moni-tor
ISA bridge
PCI bus
IDE disk
ISA bus
27
Modern GUI Devices (continued)
  • Double-buffered bitmap in Graphics card
  • Graphics and information written/drawn in back
    buffer
  • Monitor refreshes from main buffer (60 Hz)
  • Refresh interrupt at start of every frame
  • Bitblt to substitute cursor
  • CPU writes text, etc.
  • Graphics engine draws images, vectors, polygons
  • Window manager orders redraw when necessary

28
Break
  • Next Topic

29
TLB fault performance
  • Assumptions
  • m memory access time 100 nsec
  • t TLB load time from memory 300 nsec 3 m
  • Goal is lt 5 penalty for TLB misses
  • I.e., EAT lt 1.05 m
  • EAT (1-p) m p t lt 1.05 m ?p lt (0.05
    m) / (t m) 0.05 m / 2 m 0.025
  • I.e., TLB fault rate should be lt 1 per 40
    accesses!

30
TLB fault performance (continued)
  • Q How large should TLB be so that TLB faults are
    not onerous, in these circumstances?
  • A About 40 entries
Write a Comment
User Comments (0)
About PowerShow.com