C02: Interrupts and I/O

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

Computer Architecture CS 355 Busses & I/O System

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

Computer System Overview

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

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

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

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

I/O Systems. Jo, Heeseung

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

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

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

I/O SYSTEMS. Sunu Wibirama

Operating Systems 2010/2011

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

Computer Organization ECE514. Chapter 5 Input/Output (9hrs)

Operating System Review

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

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

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

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

Principles of Operating Systems CS 446/646

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

Chapter 13: I/O Systems

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

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

Hardware OS & OS- Application interface

C09: Process Synchronization

Operating Systems. V. Input / Output

CS370 Operating Systems

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

Module 12: I/O Systems

Part I Overview Chapter 1: Introduction

Module 12: I/O Systems

Input/Output Systems

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

Chapter 5 - Input / Output

Device-Functionality Progression

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

CSCI-GA Operating Systems I/O. Hubertus Franke

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)

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

Chapter 13: I/O Systems

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

Chapter-6. SUBJECT:- Operating System TOPICS:- I/O Management. Created by : - Sanjay Patel

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

Chapter 12: I/O Systems

Chapter 13: I/O Systems

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

Digital Design Laboratory Lecture 6 I/O

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

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

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

Organisasi Sistem Komputer

Common Computer-System and OS Structures

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

OPERATING SYSTEMS CS136

Chapter 13: I/O Systems

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

Chapter 6. Storage and Other I/O Topics

Storage. Hwansoo Han

Lecture 1 Introduction (Chapter 1 of Textbook)

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

Silberschatz and Galvin Chapter 12

OPERATING SYSTEMS. Goals of the Course. This lecture will cover: This Lecture will also cover:

Unit 2 : Computer and Operating System Structure

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

I/O Systems and Storage Devices

C13: Files and Directories: System s Perspective

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

[08] IO SUBSYSTEM 1. 1

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

Example Networks on chip Freescale: MPC Telematics chip

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

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

Bus System. Bus Lines. Bus Systems. Chapter 8. Common connection between the CPU, the memory, and the peripheral devices.

C06: Memory Management

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

Module 11: I/O Systems

Introduction to Computer Systems and Operating Systems

ECE 485/585 Microprocessor System Design

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks

I/O Device Controllers. I/O Systems. I/O Ports & Memory-Mapped I/O. Direct Memory Access (DMA) Operating Systems 10/20/2010. CSC 256/456 Fall

Chapter 12. CPU Structure and Function. Yonsei University

Computer Systems Laboratory Sungkyunkwan University

CS370 Operating Systems

Input Output (IO) Management

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Chapter 13: I/O Systems

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)

Input/Output Management

NWI-IBC019: Operating systems

-Device. -Physical or virtual thing that does something -Software + hardware to operate a device (Controller runs port, Bus, device)

Concurrent programming: Introduction I

Today: Computer System Overview (Stallings, chapter ) Next: Operating System Overview (Stallings, chapter ,

Chapter 3. Top Level View of Computer Function and Interconnection. Yonsei University

Transcription:

CISC 7310X C02: Interrupts and I/O Hui Chen Department of Computer & Information Science CUNY Brooklyn College 2/8/2018 CUNY Brooklyn College 1

Von Neumann Computers Process and memory connected by a bus (Von Neumann, 1945) Processor Memory Bus 2/8/2018 CUNY Brooklyn College 2

An x86 Realization A structure of a large x86 system [Figure 1-12 in Tanenbaum & Bos, 2014] 2/8/2018 CUNY Brooklyn College 3

Architecture, OS, and Programming Architecture underpins design of OS and programming Discussion on existing architecture & design How about the future? I propose to call this tube the von Neumann bottleneck. The task of a program is to change the contents of the store in some major way; when one considers that this task must be accomplished entirely by pumping single words back and forth through the von Neumann bottleneck, the reason for its name becomes clear. John Backus, 1977 2/8/2018 CUNY Brooklyn College 4

I/O Devices A few general categories Storage devices Examples: Disks, tapes, solid state drives Transmission devices Examples: network adapters, modems Human-interface devices Examples: display screens, keyboard, mouse, touch screen Specialized devices Examples: control cars, robots, aircrafts, spacecrafts 2/8/2018 CUNY Brooklyn College 5

Port and Bus Devices communicate with a computer via a connection point (Physical) port Examples: USB port, serial port, parallel port A common set of wires with a protocol that specifies commands that can be transmitted Bus Examples: PCI bus, SCSI bus 2/8/2018 CUNY Brooklyn College 6

Device Controller Devices Example: hard disk drives have motors, magnetic headers, and disks Controller A collection of electronics that operate a port, a bus, or a device (some contain small embedded computer) Accept and act on commands from the OS Present a simpler interface to the OS Examples: SATA controller 2/8/2018 CUNY Brooklyn College 7

Device Driver Device driver Each type of controller is different Software communicates to the controller, and the OS Adhere to some standard when communicating to the OS 2/8/2018 CUNY Brooklyn College 8

I/O Devices and OS Reduce complexity, increase uniformity and reliability OS Kernel Device Driver SATA Controller Device Driver USB Controller 2/8/2018 CUNY Brooklyn College 9

Design Consideration: Access Right A design consideration What kind of access right should we give to device drivers? Unrestricted Kernel mode Relatively easier to design, can affect the others Restricted User mode More difficult to design, isolated from the others 2/8/2018 CUNY Brooklyn College 10

Design Consideration: Load Device Drivers Relink the kernel with the new deriver Require reboot Add to the kernel an entry indicating a new driver is needed Load the driver during reboot Install and run the device driver on the fly Hot-pluggable 2/8/2018 CUNY Brooklyn College 11

Questions? Overview of I/O devices 2/8/2018 CUNY Brooklyn College 12

Controller Registers Typically have 4 registers or more Data-in register Read by the host Data-out register Written by the host Status register A number of bits indicating the status of the device (e.g., busy, error) Control register A number of bits indicating the mode of the device May have a data buffer Examples: video adapter (video memory) 2/8/2018 CUNY Brooklyn College 13

Virtual Box 2/8/2018 CUNY Brooklyn College 14

Access Device Controller CPU read and write to the device controller registers and data buffer (Local) I/O ports Memory mapped I/O 2/8/2018 CUNY Brooklyn College 15

I/O Port Space Each register is assigned an I/O port number Typically, a 8-bit or 16-bit integer All I/O port numbers form the I/O port space A CPU has I/O instructions Example instruction (in an assembly language): IN REG, PORT OUT PORT, REG 2/8/2018 CUNY Brooklyn College 16

Example I/O Port Allocation Some default values on PCs I/O Address Range Device 000-00F DMA Controller 020-021 Interrupt Controller 040-043 Timer 200-20F Game Controller 2F8-2FF Serial Port (Secondary) 320-32F Hard-disk Controller 378-37F Parallel Port 3D0-3DF Graphics Controller 3F0-3F7 Diskette-drive Controller 3F8-3FF Serial Port (Primary) 2/8/2018 CUNY Brooklyn College 17

I/O Instruction Example from http://www.tldp.org/howto/text/io-port- Programming Source https://github.com/cisc7310sp18/sampleprogr ams/tree/master/w2_io/ioport 2/8/2018 CUNY Brooklyn College 18

Memory Mapped I/O Map all the control registers into the memory address space A register is assigned to a unique memory address to which no memory is assigned Accessing these registers as if they were main memory Hybrid scheme Data buffers are mapped to memory address Control registers have dedicated I/O ports 2/8/2018 CUNY Brooklyn College 19

Accessing Device Controllers I/O Ports Memory-Mapped Hybrid Access controller registers [Figure 5-2 in Tanenbaum & Bos, 2014] 2/8/2018 CUNY Brooklyn College 20

Strength and Weakness Strength of memory mapped I/O Easier to program Easier to protect Faster to access Weakness (two addresses logically identical, but physically different) More complex to design cache More complex to design bus 2/8/2018 CUNY Brooklyn College 21

Questions? Access devices controller registers I/O ports Memory-mapped I/O Hybrid 2/8/2018 CUNY Brooklyn College 22

I/O Schemes Busy waiting (polling) while (busy) wait; do I/O; Interrupted I/O do something else; when (interrupted) do I/O; Direct memory access (DMA) initialize DMA; do something else; I/O done when interrupted; 2/8/2018 CUNY Brooklyn College 23

Implementing Busy Waiting Illustrate it with writing a byte Host 1. do 2. read the busy-bit in the device status register 3. while (busy) 4. set the write-bit in the control register 5. write a byte into the data-out register 6. set the command-ready bit in the control register Device Controller 1. do 2. read the command-ready bit 3. while (not set) 4. set the busy bit 5. read the byte in the data-out register 6. write the byte to the device 7. if (success) clear the command-ready bit and the busy bit 8. else set the error bit 2/8/2018 CUNY Brooklyn College 24

Interrupted I/O Conduct I/O in an asynchronous fashion Interrupted I/O[Figure 1-11 in Tanenbaum & Bos, 2014] 2/8/2018 CUNY Brooklyn College 25

Interrupted I/O Cycle CPU Initiates I/O via the device driver Execute instructions (for other tasks) and sense interrupts after each instruction Saves CPU state Runs interrupt handler to process I/O Restores CPU state Resume processing of the other tasks Device Controller Initiates I/O Does I/O (e.g., spin disk) I/O ready or error; raise interrupt-request line 2/8/2018 CUNY Brooklyn College 26

Direct Memory Access Aided by a special purpose processor called directmemory-access (DMA) controller CPU writes a DMA command block into memory Pointer to the source of transfer Pointer to the destination of transfer A count of the number of bytes to be transferred CPU writes the address of this block to the DMA controller The DMA controller does I/O by directly access devices and system bus CPU is interrupted when the DMA controller completes the transfer or encounters an error 2/8/2018 CUNY Brooklyn College 27

Operating of a DMA Transfer [Figure 5-4 in Tanenbaum & Bos, 2014] 2/8/2018 CUNY Brooklyn College 28

Questions? I/O schemes Busy waiting Interrupted I/O Direct-memory access 2/8/2018 CUNY Brooklyn College 29

Interrupts CPU senses its interrupt-request line after each instruction When it is lit, CPU saves the current state Example: push registers PSW and PC to the stack CPU jumps to the interrupt-handler routine at a fixed address in the memory Interrupt-handler routine completes its task and restore the CPU state Pop the registers from the stack 2/8/2018 CUNY Brooklyn College 30

How an Interrupt Happens? [Figure 5-5 in Tanenbaum & Bos, 2014] 2/8/2018 CUNY Brooklyn College 31

Interrupt Vectors Address to interrupt routines Some PC event/interrupt-vector numbering Vector Number Description 0 Divide Error 1 Debug Exception 6 Invalid Opcode 32-255 Maskable Interrupts (deviced generated) 2/8/2018 CUNY Brooklyn College 32

Design Consideration: Interrupts Maskable and nonmaskable interrupts Interrupt priorities and interrupt chaining Exceptions and software interrupts (traps) Precise and imprecise interrupts 2/8/2018 CUNY Brooklyn College 33

Questions? More about interrupts 2/8/2018 CUNY Brooklyn College 34

I/O Software Goals Programmed I/O Software layers Device drivers 2/8/2018 CUNY Brooklyn College 35

Goals Device independence Uniform naming Error handling 2/8/2018 CUNY Brooklyn College 36

Type of Devices Need to understand general characteristics to achieve device independent A couple of dimensions Size of transfer: Character-stream or block Access order: sequential or random access Predictability and responsiveness: Synchronous and asynchronous Shared or dedicated Speed of operation, e.g., latency, seek time, transfer rate ec Read-write, read only, or write only 2/8/2018 CUNY Brooklyn College 37

Block Devices Naming Examples on Linux by label, by uuid, by id, and by path Running examples lsblk f ls /dev/disk/ Read and write a block a time Essential behavior read(), write() For random-access block devices seek() 2/8/2018 CUNY Brooklyn College 38

Character Devices Read and write a character a time Essential behavior get(), put() 2/8/2018 CUNY Brooklyn College 39

I/O Software Layers [Figure 5-11 in Tanenbaum & Bos, 2014] 2/8/2018 CUNY Brooklyn College 40

Questions Goals of I/O software and a few examples I/O software layers 2/8/2018 CUNY Brooklyn College 41

Experiment Environment Debian Linux as a Virtual machine Need to install a few packages to make it useable Use the LKMPG as a guide https://github.com/bashrc/lkmpg 2/8/2018 CUNY Brooklyn College 42

Assignment Project 1 2/8/2018 CUNY Brooklyn College 43