I/O Devices and Drivers

Slides:



Advertisements
Similar presentations
CT213 – Computing system Organization
Advertisements

Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
Tore Larsen Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum) I/O Fall 2010.
04/14/2008CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
I/O Devices and Drivers Vivek Pai / Kai Li Princeton University.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
04/16/2010CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying an earlier edition.
I/O Systems CS 3100 I/O Hardware1. I/O Hardware Incredible variety of I/O devices Common concepts ◦Port ◦Bus (daisy chain or shared direct access) ◦Controller.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
I/O Systems CSCI 444/544 Operating Systems Fall 2008.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Copyright ©: Nahrstedt, Angrave, Abdelzaher
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
INPUT/OUTPUT ARCHITECTURE By Truc Truong. Input Devices Keyboard Keyboard Mouse Mouse Scanner Scanner CD-Rom CD-Rom Game Controller Game Controller.
Device Management. Serial Port Serial Device Serial Device Memory CPU Printer Terminal Modem Mouse etc.
CHAPTER 13: I/O SYSTEMS Overview Overview I/O Hardware I/O Hardware I/O API I/O API I/O Subsystem I/O Subsystem Transforming I/O Requests to Hardware Operations.
Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.
Input and Output Computer Organization and Assembly Language: Module 9.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-1: I/O Management Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 Chapter 13: I/O Systems I/O Hardware.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-2: I/O Management (Review) Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
I/O Systems I/O Hardware Application I/O Interface
1 Lecture 20: I/O n I/O hardware n I/O structure n communication with controllers n device interrupts n device drivers n streams.
1 Module 12: I/O Systems n I/O hardware n Application I/O Interface n Kernel I/O Subsystem n Transforming I/O Requests to Hardware Operations n Performance.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
I/O management is a major component of operating system design and operation Important aspect of computer operation I/O devices vary greatly Various methods.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5.
Chapter 13: I/O Systems. 13.2/34 Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware.
COS 318: Operating Systems I/O Device and Drivers.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
Silberschatz, Galvin and Gagne  Operating System Concepts Six Step Process to Perform DMA Transfer.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems Overview I/O Hardware Application.
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 I/O through system calls Protection.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Part IVI/O Systems Chapter 13: I/O Systems. I/O Hardware a typical PCI bus structure 2.
10/15: Lecture Topics Input/Output –Types of I/O Devices –How devices communicate with the rest of the system communicating with the processor communicating.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Introduction to Operating Systems Concepts
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Operating System I/O System Monday, August 11, 2008.
Computer Architecture
CSCI 315 Operating Systems Design
CPSC 457 Operating Systems
I/O Systems I/O Hardware Application I/O Interface
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

I/O Devices and Drivers Vivek Pai / Kai Li Princeton University

Mechanics I’ve figured out the next project Still feeling run down Regular precepts next week It should be fun, I hope Still feeling run down Office hours by appointment – e-mail My DSL connection is bad Makes working from home harder

Gaining Flexibility Question: how do you make a file descriptor refer to non-files? Answer: treat it as an object System calls have a shared part of code Actual work done by calls to function ptrs Each type of object exports a structure of func ptrs that handle all file-related syscalls

Overview Data must enter/leave the system How do we communicate with devices? How does data get transferred? How do we structure the OS? How do we increase flexibility?

Definitions & General Method Overhead CPU time to initiate operation (cannot be overlapped) Latency Time to perform 1-byte I/O operation Bandwidth Rate of I/O transfer, once initiated General method Abstraction of byte transfers Batch transfers into block I/O for efficiency to prorate overhead and latency over a large unit

Overview Data must enter/leave the system How do we communicate with devices? Special instructions (in/out port/device) Memory-mapped – logic on adaptor How does data get transferred? How do we structure the OS? How do we increase flexibility?

Overview Data must enter/leave the system How do we communicate with devices? How does data get transferred? Each byte moved manually – handshaking Separate engine arranges movement How do we structure the OS? How do we increase flexibility?

Programmed I/O “Slow” Input Device CPU Device Data registers Status register (ready, busy, interrupt, … ) A simple mouse design Put (X, Y) in data registers on a move Interrupt Perform an input On an interrupt reads values in X, Y registers sets ready bit wakes up a process/thread or execute a piece of code Memory L2 Cache I/O Bus Interface X Y

Programmed I/O Output Device Data registers Status registers (ready, busy, … ) Perform an output Polls the busy bit Writes the data to data register(s) Sets ready bit Controller sets busy bit and transfers data Controller clears the ready bit and busy bit

Direct Memory Access (DMA) Free to move data during DMA Perform DMA from host CPU Device driver call (kernel mode) Wait until DMA device is free Initiate a DMA transaction (command, memory address, size) Block DMA interface DMA data to device (size--; address++) Interrupt on completion (size == 0) Interrupt handler (on completion) Wakeup the blocked process CPU Memory L2 Cache I/O Bus DMA Interface

Overview Data must enter/leave the system How do we communicate with devices? How does data get transferred? How do we structure the OS? Standard interface between OS/device Moves “intimate knowledge” out of OS How do we increase flexibility?

Device Drivers . Rest of the operating system I/O System . Device controller Device driver Device Device controller Device driver Device . . Device Device controller Device driver Device

Device Driver Design Issues Operating system and driver communication Commands and data between OS and device drivers Driver and hardware communication Commands and data between driver and hardware Driver operations Initialize devices Interpreting commands from OS Schedule multiple outstanding requests Manage data transfers Accept and process interrupts Maintain the integrity of driver and kernel data structures

Device Driver Interface Open( deviceNumber ) Initialization and allocate resources (buffers) Close( deviceNumber ) Cleanup, deallocate, and possibly turnoff Device driver types Block: fixed sized block data transfer Character: variable sized data transfer Terminal: character driver with terminal control Network: streams for networking

Block Device Interface read( deviceNumber, deviceAddr, bufferAddr ) transfer a block of data from “deviceAddr” to “bufferAddr” write( deviceNumber, deviceAddr, bufferAddr ) transfer a block of data from “bufferAddr” to “deviceAddr” seek( deviceNumber, deviceAddress ) move the head to the correct position usually not necessary

Character Device Interface read( deviceNumber, bufferAddr, size ) reads “size” bytes from a byte stream device to “bufferAddr” write( deviceNumber, bufferAddr, size ) write “size” bytes from “bufferSize” to a byte stream device

Unix Device Driver Interface Entry Points init(): Initialize hardware start(): Boot time initialization (require system services) open(dev, flag, id): initialization for read or write close(dev, flag, id): release resources after read and write halt(): call before the system is shutdown intr(vector): called by the kernel on a hardware interrupt read/write calls: data transfer poll(pri): called by the kernel 25 to 100 times a second ioctl(dev, cmd, arg, mode): special request processing

Overview Data must enter/leave the system How do we communicate with devices? How does data get transferred? How do we structure the OS? How do we increase flexibility? Sync/Async I/O, buffering in kernel Dynamic loading/binding

Why Buffering Speed mismatch between producer and consumer Character device and block device, for example Adapt different data transfer sizes Packets vs. streams Support copy semantics Deal with address translation I/O devices see physical memory, but programs use virtual memory Spooling Avoid deadlock problems Caching Avoid I/O operations

Detailed Steps of Blocked Read A process issues a read call which executes a system call System call code checks for correctness and cache If it needs to perform I/O, it will issues a device driver call Device driver allocates a buffer for read and schedules I/O Controller performs DMA data transfer, blocks the process Device generates an interrupt on completion Interrupt handler stores any data and notifies completion Move data from kernel buffer to user buffer and wakeup blocked process User process continues

Asynchronous I/O Why do we want asynchronous I/O? Life is simple if all I/O is synchronous How to implement asynchronous I/O? On a read copy data from a system buffer if the data is there Otherwise, initiate I/O How does process find out about completion? On a write copy to a system buffer, initiate the write and return

Other Design Issues Build device drivers statically dynamically How to down load device driver dynamically? load drivers into kernel memory install entry points and maintain related data structures initialize the device drivers

Dynamic Binding with An Indirect Table Open( 1, … ); Indirect table Driver for device 0 … open(…) { } Driver-kernel interface read(…) { } Interrupt handlers Driver for device 1 … open(…) { } Other Kernel services read(…) { }

Dynamic Binding Download drivers by users (may require a reboot) Allocate a piece of kernel memory Put device driver into the memory Bind device driver with the device Pros: flexible and support ISVs and IHVs Cons: security holes

Think About Performance A terminal connects to computer via a serial line Type character and get characters back to display RS-232 is bit serial: start bit, character code, stop bit (9600 baud) Do we have any cycles left? 10 users or 10 modems 900 interrupts/sec per user Overhead of handing an interrupt = 100 msec