CSE 451: Operating Systems Spring 2008 Module 15 I/O

Slides:



Advertisements
Similar presentations
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Advertisements

Principles of I/O Hardware I/O Devices Block devices, Character devices, Others Speed Device Controllers Separation of electronic from mechanical components.
Categories of I/O Devices
I/O Systems Operating System Concepts chapter 13 CS 355
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface.
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.
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.
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.
Memory Management, File Systems, I/O How Multiprogramming Issues Mesh ECEN 5043 Software Engineering of Multiprogram Systems University of Colorado, Boulder.
Device Management.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
CHAPTER 9: Input / Output
I/O Systems CSCI 444/544 Operating Systems Fall 2008.
CSE 451: Operating Systems Winter 2010 Module 15 I/O Mark Zbikowski Gary Kimura.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
1 Input/Output. 2 Principles of I/O Hardware Some typical device, network, and data base rates.
CHAPTER 9: Input / Output
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-1: I/O Management Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
NETW 3005 I/O Systems. Reading For this lecture, you should have read Chapter 13 (Sections 1-4, 7). NETW3005 (Operating Systems) Lecture 10 - I/O Systems2.
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:
I/O Systems I/O Hardware Application I/O Interface
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
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.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 13: I/O Systems I/O Hardware Application I/O Interface.
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.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems Overview I/O Hardware Application.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
I/O Software CS 537 – Introduction to Operating Systems.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
Introduction to Operating Systems Concepts
Chapter 13: I/O Systems.
I/O Management.
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.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Operating Systems (CS 340 D)
CS 286 Computer Organization and Architecture
CS703 - Advanced Operating Systems
Computer Architecture
CSCI 315 Operating Systems Design
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
Selecting a Disk-Scheduling Algorithm
CS703 - Advanced Operating Systems
Chapter 5: I/O Systems.
CSE 451: Operating Systems Spring 2007 Module 15 I/O
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardwared Application I/O Interface
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

CSE 451: Operating Systems Spring 2008 Module 15 I/O Mark Zbikowski Gary Kimura 1

What’s Ahead Principles of I/O Hardware Structuring of I/O Software Layers of an I/O System Operation of an I/O System 1/12/2019

Hardware Environment Major components of a computer system: CPU, memories (primary/secondary), I/O system I/O devices: Block devices – store information in fixed-sized blocks; typical sizes: 128-4096 bytes Character devices – delivers/accepts stream of characters (bytes) Device controllers: Connects physical device to system bus (Minicomputers, PCs) Mainframes use a more complex model: Multiple buses and specialized I/O computers (I/O channels) Communication: Memory-mapped I/O, controller registers Direct Memory Access - DMA 1/12/2019

I/O Hardware - Single Bus Monitor Keyboard Floppy drive Disk drive CPU Memory Video Controller Keyboard Controller Floppy Controller Disk Controller System bus 1/12/2019

I/O Hardware - Multiple Buses Memory bus SCSI disk CPU PCI bridge/ memory controller Memory SCSI disk Cache SCSI disk SCSI bus Video controller Network controller SCSI controller PCI bus IDE disk controller USB interface keyboard mouse USB bus 1/12/2019

Diversity among I/O Devices The I/O subsystem has to consider device characteristics: Data rate: may vary by several orders of magnitude Complexity of control: exclusive vs. shared devices Unit of transfer: stream of bytes vs. block-I/O Data representations: character encoding, error codes, parity conventions Error conditions: consequences, range of responses Applications: impact on resource scheduling, buffering schemes 1/12/2019

Organization of the I/O Function Programmed I/O with polling: The processor issues an I/O command on behalf of a process The process busy waits for completion of the operation before proceeding Interrupt-driven I/O: The processor issues an I/O command and continues to execute The I/O module interrupts the processor when it has finished I/O The initiator process may be suspended pending the interrupt Direct memory access (DMA): A DMA module controls exchange of data between I/O module and main memory The processor requests transfer of a block of data from DMA and is interrupted only after the entire block has been transferred 1/12/2019

Flow of a blocking I/O request Thread issues blocking read() system call Kernel checks parameters; may return buffered data and finish Idle device: Driver allocates kernel buffer; sends command to controller Busy device: Driver puts I/O request on device queue Thread is removed from run queue; added to wait queue for device Interrupt occurs; handler stores data; signals device driver to release first thread on device wait queue Handler takes next request from queue, allocates kernel buffer; sends command to controller Awoken thread is in device driver, cleans up Thread resumes execution at completion of read() call 1/12/2019

Flow of an asynchronous I/O request Thread issues readasync() system call with synchronization object Kernel checks parameters; may return buffered data immediately, signal synchronization object and finish I/O request is scheduled (initiated on hardware or queued in device driver if busy) Thread returns from readasync() Thread continues, and eventually issues wait(synchronization object) Interrupt occurs, driver retrieves data from hardware if necessary (PIO) Interrupt code starts next request, if any Interrupt code calls wakeup(synchronization object) Interrupt code returns Only a slight difference from blocking call: use process’s synchronization object But what code really can run during interrupts? 1/12/2019

Interrupt-time code Kernel/user interruptions occur at arbitrary points Inconsistent data (linked lists not set up correctly, data structures in transition) What’s the least that can be counted on? MM? No. Kernel needs to deliver an environment where efficient/effective processing can be performed Linux/Unix: scheduler is the only thing available. The interrupt code will wakeup() the thread that is awaiting service. Some drivers will be able to start next request at this time. Windows: scheduler is available but also means for enqueueing DPC/APC (Deferred Procedure Call/Asynchronous Procedure Call) 1/12/2019

DPC/APC – What? An architecture for executing a body of code in a clean environment without a context switch. Kernel has notion of IRQL (I/O Request Level). Interrupts from hardware have certain priorities: timer, disk, keyboard/mouse IRQL is used to mask lower levels so that timely/correct responses can be made; interrupts with lower priority are held off until IRQL is lowered Control is arbitrated through PIC IRQL is union of hardware and software interrupt events: DPC and APC are lower priority than HW interrupts KeRaiseIrql() and KeLowerIrql() 1/12/2019

IRQLs Example: Power Fail Inter-processor interrupt Clock Device N .. Device 0 DPC/Dispatch APC Passive (aka running user code) 1/12/2019

DPC – deferred procedure call A DPC procedure is called in an environment that allows calling scheduler primitives (wait(), yield(), wake()), access timers, reschedule when quantum expires Executes in the current thread when IRQL is lowered sufficiently. Used by device drivers to minimize the amount of work performed during H/W interrupt. Why? Cannot block! (not touch paged-out memory, take spinlocks, etc) 1/12/2019

APC – Asyncrhonous Procedure Call “Lower priority interrupt” than DPC. Only executes when no other pending DPCs exist Can execute at “current” thread or “that” thread. Has full range of kernel services (I/O, MM, synchronization, etc). 1/12/2019

Linux/Unix I/O Device Interrupt Processing Interrupt occurs, interrupt handler saves state Wakes up thread that was waiting on I/O Selects next request to process Wakes up corresponding thread A Returns from interrupt … Context switch to thread A Issue commands to device Waits on completion Context switch to … 1/12/2019

Windows I/O Device Interrupt Processing Interrupt occurs, interrupt handler saves state Enables DPC Returns from interrupt DPC executes Wakes up thread waiting on I/O Enables APC in current thread Exits DPC APC executes Selects next request to process Issue commands to device Exits APC NO CONTEXT SWITCHES! 1/12/2019

Principles of I/O Software Structuring of I/O software User-level software Device-independent OS software Device drivers Interrupt handlers Layered organization Device independence Error handling Error should be handled as close to the hardware as possible Transparent error recovery at low level Synchronous vs. Asynchronous transfers Most physical I/O is asynchronous Kernel may provide synchronous I/O system calls Sharable vs. dedicated devices Disk vs. printer 1/12/2019

Interrupt Handlers Should be hidden by the operating system Every thread starting an I/O operation should block until I/O has completed and interrupt occurs (OS with no async system calls) Interrupt handler transfers data from device (controller) and un-blocks process 1/12/2019

Device Driver Contains all device-dependent code Handles one device Translates abstract requests into device commands Writes controller registers Accesses mapped memory Queues requests Driver may block after issuing a request: Interrupt will un-block driver (returning status information) 1/12/2019

Device-independent I/O Software Functions of device-independent I/O software: Uniform interfacing for the device drivers Device naming Device protection Providing a device-independent block size Buffering Storage allocation on block devices Allocating and releasing dedicated devices Error reporting 1/12/2019

Layers of the I/O System User-Space I/O Software System call libraries (read, write,...) Spooling Managing dedicated I/O devices in a multiprogramming system Daemon process, spooling directory lpd – line printer daemon, sendmail – simple mail transfer protocol Layer User process Device-independent software Device drivers Interrupt handlers Hardware I/O request I/O reply I/O functions I/O calls, spooling format I/O Naming, protection buffering, blocking Setup registers, Check status Wakeup driver Perform I/O op. 1/12/2019

Application I/O Interfaces The OS system call interface distinguished device classes: Character-stream or block Sequential or random-access Synchronous or asynchronous Sharable or dedicated Speed of operation Read/write, read only, write only 1/12/2019