CSE 451: Operating Systems Winter I/O System. Gary Kimura

Similar documents
Input-Output (I/O) Input - Output. I/O Devices. I/O Devices. I/O Devices. I/O Devices. operating system must control all I/O devices.

I/O Handling. ECE 650 Systems Programming & Engineering Duke University, Spring Based on Operating Systems Concepts, Silberschatz Chapter 13

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

I/O Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Module 12: I/O Systems

CS330: Operating System and Lab. (Spring 2006) I/O Systems

Module 12: I/O Systems

Comp 204: Computer Systems and Their Implementation. Lecture 18: Devices

Device-Functionality Progression

Chapter 12: I/O Systems. I/O Hardware

Chapter 13: I/O Systems

Devices. Today. Comp 104: Operating Systems Concepts. Operating System An Abstract View 05/01/2017. Devices. Devices

Chapter 13: I/O Systems

Module 11: I/O Systems

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

[08] IO SUBSYSTEM 1. 1

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Chapter 13: I/O Systems. Objectives. I/O Hardware. A Typical PC Bus Structure. Device I/O Port Locations on PCs (partial)

The control of I/O devices is a major concern for OS designers

Chapter 5 Input/Output. I/O Devices

CS 134. Operating Systems. April 8, 2013 Lecture 20. Input/Output. Instructor: Neil Rhodes. Monday, April 7, 14

Today: I/O Systems. Architecture of I/O Systems

Chapter 13: I/O Systems

I/O Systems. 04/16/2007 CSCI 315 Operating Systems Design 1

Chapter 13: I/O Systems

Input/Output Systems

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

Chapter 13: I/O Systems

Operating Systems. V. Input / Output

I/O Systems. Jo, Heeseung

I/O SYSTEMS. Sunu Wibirama

Lecture 15: I/O Devices & Drivers

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Operating Systems. Lecture 09: Input/Output Management. Elvis C. Foster

Lecture 13 Input/Output (I/O) Systems (chapter 13)

Windows Interrupts

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

Chapter 13: I/O Systems

Chapter 13: I/O Systems

CS370 Operating Systems

操作系统概念 13. I/O Systems

CS370 Operating Systems

CSE 4/521 Introduction to Operating Systems. Lecture 24 I/O Systems (Overview, Application I/O Interface, Kernel I/O Subsystem) Summer 2018

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

CSCI-GA Operating Systems I/O. Hubertus Franke

CSE 120. Overview. July 27, Day 8 Input/Output. Instructor: Neil Rhodes. Hardware. Hardware. Hardware

OPERATING SYSTEMS CS136

Input Output (IO) Management

COT 4600 Operating Systems Fall Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM

I/O Management Intro. Chapter 5

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

Computer System Overview

Unit 2 : Computer and Operating System Structure

I/O Devices. I/O Management Intro. Sample Data Rates. I/O Device Handling. Categories of I/O Devices (by usage)

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

19: I/O. Mark Handley. Direct Memory Access (DMA)

Computer Architecture CS 355 Busses & I/O System

Operating Systems (CS1022) Input/Output. Yagiz Özbek Evren

Computer System Overview OPERATING SYSTEM TOP-LEVEL COMPONENTS. Simplified view: Operating Systems. Slide 1. Slide /S2. Slide 2.

Operating Systems 2010/2011

Last class: Today: Course administration OS definition, some history. Background on Computer Architecture

7/20/2008. What Operating Systems Do Computer-System Organization

Input/Output Problems. External Devices. Input/Output Module. I/O Steps. I/O Module Function Computer Architecture

Silberschatz and Galvin Chapter 12

Process Scheduling Queues

Outline. Operating Systems: Devices and I/O p. 1/18

Input / Output. School of Computer Science G51CSA

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

I/O Management and Disk Scheduling. Chapter 11

Input/Output Systems

I/O. CS 416: Operating Systems Design Department of Computer Science Rutgers University


NWI-IBC019: Operating systems

Introduction. CS3026 Operating Systems Lecture 01

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. (done)

UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

I/O Design, I/O Subsystem, I/O-Handler Device Driver, Buffering, Disks, RAID January WT 2008/09

Organisasi Sistem Komputer

Processes and Non-Preemptive Scheduling. Otto J. Anshus

I/O and Device Drivers

Operating System Design Issues. I/O Management

Introduction I/O 1. I/O devices can be characterized by Behavior: input, output, storage Partner: human or machine Data rate: bytes/sec, transfers/sec

Generic Model of I/O Module Interface to CPU and Memory Interface to one or more peripherals

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Windows History 2009 Windows 7 2

Chapter 1: Introduction. Chapter 1: Introduction

C02: Interrupts and I/O

Operating Systems. Steven Hand. Michaelmas / Lent Term 2008/ lectures for CST IA. Handout 4. Operating Systems

Chapter 1: Introduction

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. One OS function is to control devices

Input/Output Management

Scuola Superiore Sant Anna. I/O subsystem. Giuseppe Lipari

Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications

5.b Principles of I/O Hardware CPU-I/O communication

Mon Sep 17, 2007 Lecture 3: Process Management

Transcription:

CSE 451: Operating Systems Winter 2012 I/O System Gary Kimura

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 2

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 3

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

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

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 6

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 7

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

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

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 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) 10

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() 11

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

DPC deferred procedure call A DPC procedure is called in an environment that allows calling scheduler primitives (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) 13

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). 14

Unix I/O Device Interrupt Processing 1. Interrupt occurs, interrupt handler saves state 2. Wakes up thread that was waiting on I/O 3. Selects next request to process 4. Wakes up corresponding thread A 5. Returns from interrupt 6. 7. Context switch to thread A 8. Issue commands to device 9. Waits on completion 10.Context switch to 15

Windows I/O Device Interrupt Processing 1. Interrupt occurs, interrupt handler saves state 2. Enables DPC 3. Returns from interrupt 4. DPC executes 5. Wakes up thread waiting on I/O 6. Enables APC in current thread 7. Exits DPC 8. APC executes 9. Selects next request to process 10.Issue commands to device 11.Exits APC 12.NO CONTEXT SWITCHES! 16

Principles of I/O Software 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 Structuring of I/O software 1. User-level software 2. Device-independent OS software 3. Device drivers 4. Interrupt handlers 17

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 18

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) 19

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 20

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 I/O request Layer I/O reply User process Device-independent software Device drivers Interrupt handlers Hardware I/O functions I/O calls, spooling format I/O Naming, protection buffering, blocking Setup registers, Check status Wakeup driver Perform I/O op. 21

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 22