Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS-3013 & CS-502, Summer 2006 Input / Output1 Input and Output CS-3013 & CS502 Operating Systems Summer 2006.

Similar presentations


Presentation on theme: "CS-3013 & CS-502, Summer 2006 Input / Output1 Input and Output CS-3013 & CS502 Operating Systems Summer 2006."— Presentation transcript:

1 CS-3013 & CS-502, Summer 2006 Input / Output1 Input and Output CS-3013 & CS502 Operating Systems Summer 2006

2 CS-3013 & CS-502, Summer 2006 Input / Output2 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 CS-3013 & CS-502, Summer 2006 Input / Output3 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 CS-3013 & CS-502, Summer 2006 Input / Output4 Review (continued) Types of devices –Character, block, graphical, clocks & other –Controlling a device Programmed I/O, Interrupt-driven, DMA

5 CS-3013 & CS-502, Summer 2006 Input / Output5 Outline for this evening I/O continued: device drivers Network I/O Programming Project #3 Disks

6 CS-3013 & CS-502, Summer 2006 Input / Output6 Device Drivers Organization Static or dynamic Uniform interfaces to OS Uniform buffering strategies Hide device idiosyncrasies

7 CS-3013 & CS-502, Summer 2006 Input / Output7 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 CS-3013 & CS-502, Summer 2006 Input / Output8 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 CS-3013 & CS-502, Summer 2006 Input / Output9 Uniform API and Buffering Example Memory-mapped Keyboard /dev/kb Device interrupt routine detects key transitions Driver converts sequence of transitions into characters in user’s 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 CS-3013 & CS-502, Summer 2006 Input / Output10 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 CS-3013 & CS-502, Summer 2006 Input / Output11 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 CS-3013 & CS-502, Summer 2006 Input / Output12 Dynamic Device Configuration At boot time:– 1.Probe hardware for inventory of devices & addresses 2.Map devices to drivers (using table previously created) 3.Load necessary drivers into kernel space, register in interrupt vector (.sys files in Windows) Run time:– 1.Detect interrupt from newly added device 2.Search for driver, or ask user; add to table 3.Load into kernel space, register in interrupt vector

13 CS-3013 & CS-502, Summer 2006 Input / Output13 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 CS-3013 & CS-502, Summer 2006 Input / Output14 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 CS-3013 & CS-502, Summer 2006 Input / Output15 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 CS-3013 & CS-502, Summer 2006 Input / Output16 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 CS-3013 & CS-502, Summer 2006 Input / Output17 User Space I/O example Print 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 CS-3013 & CS-502, Summer 2006 Input / Output18 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 CS-3013 & CS-502, Summer 2006 Input / Output19 A special kind of Device The 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 CS-3013 & CS-502, Summer 2006 Input / Output20 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 Main Memory CPU Bitmap Digital to Analog Video

21 CS-3013 & CS-502, Summer 2006 Input / Output21 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 ABCDEF … Bitmap bitblt Dog

22 CS-3013 & CS-502, Summer 2006 Input / Output22 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 2 p, for p-bit pixels Each entry (usually) 8 bits each for RGB

23 CS-3013 & CS-502, Summer 2006 Input / Output23 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 CS-3013 & CS-502, Summer 2006 Input / Output24 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 CS-3013 & CS-502, Summer 2006 Input / Output25 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 CS-3013 & CS-502, Summer 2006 Input / Output26 Modern GUI Devices ISA bridge IDE disk Main Memory CPU Level 2 cache Bridge Moni- tor Graphics card USB Key- board Mouse Ether- net SCSI Modem Sound card Printer PCI bus ISA bus AGP Port

27 CS-3013 & CS-502, Summer 2006 Input / Output27 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 CPU Bridge Moni- tor Graphics card

28 CS-3013 & CS-502, Summer 2006 Input / Output28 Break Next Topic

29 CS-3013 & CS-502, Summer 2006 Input / Output29 TLB fault performance Assumptions –m = memory access time = 100 nsec –t = TLB load time from memory = 300 nsec = 3 * m Goal is < 5% penalty for TLB misses –I.e., EAT < 1.05 * m EAT = (1-p) * m + p * t < 1.05 *m  p < (0.05 * m) / (t – m) = 0.05 * m / 2 * m = 0.025 I.e., TLB fault rate should be < 1 per 40 accesses!

30 CS-3013 & CS-502, Summer 2006 Input / Output30 TLB fault performance (continued) Q: How large should TLB be so that TLB faults are not onerous, in these circumstances? A: About 40 entries


Download ppt "CS-3013 & CS-502, Summer 2006 Input / Output1 Input and Output CS-3013 & CS502 Operating Systems Summer 2006."

Similar presentations


Ads by Google