Slide 5-1. Device. Management. Operating Systems: A Modern Perspective, Chapter 5. Copyright 2004 Pearson Education, Inc.

Similar documents
Input/Output Systems

The Device Driver Interface. Input/Output Devices. System Call Interface. Device Management Organization

Computer Organization

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

Input/Output Systems

Device-Functionality Progression

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

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

Chapter 13: I/O Systems

Module 12: I/O Systems

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)

Chapter 13: I/O Systems

Chapter 12: I/O Systems

Chapter 13: I/O Systems

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

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

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

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

Module 12: I/O Systems

Module 11: I/O Systems

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

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

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

Chapter 13: I/O Systems

Operating Systems 2010/2011

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

I/O SYSTEMS. Sunu Wibirama

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

Chapter 13: I/O Systems

Chapter 13: I/O Systems

CS 201. Exceptions and Processes. Gerson Robboy Portland State University

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

[08] IO SUBSYSTEM 1. 1

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

Operating System. Chapter 3. Process. Lynn Choi School of Electrical Engineering

I/O Systems. Jo, Heeseung

Chapter 13: I/O Systems

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

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

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

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

Lecture 15: I/O Devices & Drivers

Architectural Support for Operating Systems

Chapter 5 Input/Output. I/O Devices

CS370 Operating Systems

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

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

Silberschatz and Galvin Chapter 12

Principles of Operating Systems CS 446/646

CS370 Operating Systems

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

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

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

Hardware OS & OS- Application interface

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

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

UNIT- 5. Chapter 12 Processor Structure and Function

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.

Chapter 13: I/O Systems

Systems Programming and Computer Architecture ( ) Timothy Roscoe

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

Anne Bracy CS 3410 Computer Science Cornell University

CPU Structure and Function

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)

Operating Systems CMPSC 473. Input/Output April 22, Lecture 22 Instructor: Trent Jaeger

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

CPU Structure and Function. Chapter 12, William Stallings Computer Organization and Architecture 7 th Edition

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

Introduction to I/O. 1-Slide Overview to File Management

Computer System Overview

NWI-IBC019: Operating systems

ECE 485/585 Microprocessor System Design

Input / Output. Kevin Webb Swarthmore College April 12, 2018

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

CSC 2405: Computer Systems II

Operating Systems. V. Input / Output

OS Structure. Kevin Webb Swarthmore College January 25, Relevant xkcd:

Anne Bracy CS 3410 Computer Science Cornell University

Operating Systems. Steven Hand. Michaelmas / Lent Term 2008/ lectures for CST IA. Handout 4. 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

C02: Interrupts and I/O

CS510 Operating System Foundations. Jonathan Walpole

CPS104 Computer Organization and Programming Lecture 17: Interrupts and Exceptions. Interrupts Exceptions and Traps. Visualizing an Interrupt

Chapter 12. CPU Structure and Function. Yonsei University

Summer 2003 Lecture 1 06/09/03

Introduction. CS3026 Operating Systems Lecture 01

CIS Operating Systems I/O Systems & Secondary Storage. Professor Qiang Zeng Spring 2018

OPERATING SYSTEMS CS136

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

Review: Hardware user/kernel boundary

ECE 650 Systems Programming & Engineering. Spring 2018

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

CSCE Introduction to Computer Systems Spring 2019

What is an Operating System? A Whirlwind Tour of Operating Systems. How did OS evolve? How did OS evolve?

I/O Management and Disk Scheduling. Chapter 11

CS 111. Operating Systems Peter Reiher

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

Transcription:

Slide 5-1 Device 5 Management

Announcements Slide 5-2 Homework Set #1 due Thursday 11 am, see moodle copyright issues with lectures Program Assignment #1 coming soon Read chapters 4 and 5 skip sections 4.7, 4.8 skip Sections 5.4, 5.5 for now

Slide 5-3 Determining When I/O is Complete CPU CPU Interrupt Pending Device Device Device Device Device Device CPU incorporates an interrupt pending flag When device.busy FALSE, interrupt pending flag is set Hardware tells OS that the interrupt occurred Interrupt handler part of the OS makes process ready to run

Control Unit with Interrupt Slide 5-4 (Hardware) PC = <machine start address>; IR = memory[pc]; haltflag = CLEAR; while(haltflag not SET) { execute(ir); PC = PC + sizeof(instruct); IR = memory[pc]; if(interruptrequest) { memory[0] = PC; PC = memory[1] }; could be a trap instr. memory[1] contains the address of the interrupt handler

Examples of Exceptions in Pentium Slide 5-5 Systems Class Cause Async/ Trap Fault Abort Interrupt Intentional exception Potentially recoverable error nonrecoverable error signal from I/O device Sync Sync Sync Sync Async Return behavior always returns to next instruction might return to current instruction never returns always returns to next instruction

The Trap Instruction Operation Slide 5-6 1 Mode S Branch Table a trap is a software interrupt trap 2 3 Trusted Code User Supervisor hardware interrupts behave similarly, an interrupt gives an offset into interrupt vector table

Examples of Exceptions in Pentium Slide 5-7 Exception Number Systems Exception Table, also called Branch Table or Jump Table or Interrupt Vector Description Exception Class 0 Divide error fault 13 General protection fault fault 14 Page fault fault nonmaskable OS assigns 18 machine check abort 32-127 OS-defined Interrupt or trap 128 System call Trap 129-255 OS-defined Interrupt or trap maskable interrupts

Maskable Interrupts Slide 5-8 Maskable interrupts can be turned off by CPU before execution of critical instruction sequences are used by device controllers to talk with CPU Nonmaskable interrupts/exceptions is reserved for events such as unrecoverable memory errors and cannot be turned off by the CPU Can have multiple interrupt priority levels high-priority interrupts can preempt execution of a lowpriority interrupt

Disabling Maskable Interrupts Slide 5-9 saveprocessorstate() { for(i=0; i<numberofregisters; i++) memory[k+i] = R[i]; for(i=0; i<numberofstatusregisters; i++) memory[k+numberofregisters+i] = StatusRegister[i]; } PC = <machine start address>; IR = memory[pc]; haltflag = CLEAR; while(haltflag not SET) { execute(ir); PC = PC + sizeof(instruct); IR = memory[pc]; if(interruptrequest && InterruptEnabled) { disableinterupts(); memory[0] = PC; PC = memory[1] }; have to reenable interrupts after done

Classes of System Calls Invoked by Slide 5-10 trap Process control File Management Device Management system call interface Information Communications Management end, abort load, execute create, terminate get attributes, set wait for time wait event, signal event allocate memory, free create, delete open, close read, write, reposition get attributes, set request device, release read, write, reposition get attributes, set logically attach or detach devices Note Similarity get time/date, set get system data, set get process, file, or device attributes, set create connection, delete send messages, receive transfer status info attach remote devices, detach

The Device Driver Interface Slide 5-11 write( ); Device Interface Terminal Driver Driver Printer Printer Driver Driver Disk Disk Driver Driver Terminal Controller Printer Printer Controller Disk Disk Controller

Device Management Organization Slide 5-12 System Interface Application Process e.g. write() File Manager Hardware Interface Command Device-Independent Device-Dependent Status Device Controller Data Data Device Manager or I/O Subsystem drivers

Device System Call Interface Slide 5-13 Functions available to application programs Abstract all devices (and files) to a few interfaces Make interfaces as similar as possible Block vs character Sequential vs direct/random access Blocking versus Non-Blocking I/O blocking system call: process put on wait queue until I/O completes non-blocking system call: returns immediately with partial number of bytes transferred, e.g. keyboard, mouse, network sockets Synchronous versus asynchronous asynchronous returns immediately, but at some later time, the full number of bytes requested is transferred Device driver implements functions (one entry point per API function)

Example: BSD UNIX Driver Slide 5-14 open close ioctl read write strategy select stop Prepare dev for operation No longer using the device Character dev specific info Character dev input op Character dev output op Block dev input/output ops Character dev check for data Discontinue a stream output op

Device Independent Function Call Slide 5-15 Trap Table func i ( ) dev_func_i(devid, ) { // Processing common to all devices switch(devid) { case dev0: dev0_func_i( ); case dev1: case devm: break; dev1_func_i( ); break; devm_func_i( ); break; }; // Processing common to all devices }

Overlapping the Operation of a Slide 5-16 Device and the CPU... read(dev_i, %d, x); y = f(x)...... startread(dev_i, %d, x);... While(stillReading()) ; y = f(x)... Data on device Variable x Register Device dev_i Memory CPU

Overlapping CPU-Controller Slide 5-17 Operations in a Process could be non-blocking or asynchronous system call App I/O Ctlr t 1 t 2 t 3 t 4 t 5 t 6 t 7 t 8 t 9

Overlapping Processing and I/O Slide 5-18 App1 makes a blocking or synchronous system call App 1 App 2 I/O Ctlr t 1 t 2 t 3 t 4

Device Manager I/O Strategies Slide 5-19 Underneath the blocking/non-blocking synchronous/asynchronous system call API, OS can implement several strategies for I/O with devices direct I/O with polling direct I/O with interrupts DMA with interrupts

Polling I/O Read Operation Slide 5-20 System Interface 1 read(device, ); Data 2 3 4 read driver write driver 5 Hardware Interface Command Status Status Data Data Device Controller

Interrupt-driven I/O Operation Slide 5-21 1 System Interface read(device, ); Data 9 8b Device Status Table 3 2 read driver write driver 4 7 Device Device Handler Handler Interrupt Handler Handler 6 8a Hardware Interface 5 Command Status Status Data Data Device Controller

Driver-Kernel Interface Slide 5-22 Drivers are distinct from main part of kernel Kernel makes calls on specific functions, drivers implement them Drivers use kernel functions for: Device allocation Resource (e.g., memory) allocation Scheduling etc. (varies from OS to OS)

DMA with Interrupts Example Slide 5-23 5. DMA sends each byte to memory 6. DMA interrupts CPU when done 1. device driver told to transfer bytes from disk to memory 2. dev driver informs disk controller DMA/bus/interrupt Controller CPU CPU/Memory Bus I/O Bus Disk Controller Memory 3. disk controller initiates DMA 4. disk controller sends each byte to DMA controller

Handling Interrupts Slide 5-24 Device driver J int read( ) { // Prepare for I/O save_state(j); out dev# // Done (no return) } Device status table J Device interrupt handler J void dev_handler( ) { get_state(j); //Cleanup after op signal(dev[j]); return_from_sys_call(); } Interrupt Handler Device Controller

Handling Interrupts(2) Slide 5-25 Device driver J int read( ) { out dev# // Return after interrupt wait(dev[j}); return_from_sys_call(); } Device interrupt handler J void dev_handler( ) { //Cleanup after op signal(dev[j]); } Interrupt Handler Device Controller