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

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

Computer Architecture CS 355 Busses & I/O System

OPERATING SYSTEMS CS136

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

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

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

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

CSE 120. Operating Systems. March 27, 2014 Lecture 17. Mass Storage. Instructor: Neil Rhodes. Wednesday, March 26, 14

Input/Output Systems

Organisasi Sistem Komputer

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

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

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

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

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

Chapter 8. A Typical collection of I/O devices. Interrupts. Processor. Cache. Memory I/O bus. I/O controller I/O I/O. Main memory.

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

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

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

Silberschatz and Galvin Chapter 12

I/O SYSTEMS. Sunu Wibirama

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

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

Hardware OS & OS- Application interface

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

Module 11: I/O Systems

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

Chapter 5 Input/Output. I/O Devices

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

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

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

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

Computer System Overview

Interfacing. Introduction. Introduction Addressing Interrupt DMA Arbitration Advanced communication architectures. Vahid, Givargis

Device-Functionality Progression

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

[08] IO SUBSYSTEM 1. 1

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

Module 12: I/O Systems

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

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

Module 12: I/O Systems

Digital Design Laboratory Lecture 6 I/O

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

Answer to exercises chap 13.2

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 AND DEVICE HANDLING Operating Systems Design Euiseong Seo

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

Operating Systems 2010/2011

C02: Interrupts and I/O

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)

COSC 243. Input / Output. Lecture 13 Input/Output. COSC 243 (Computer Architecture)

I/O and Device Drivers


Chapter 13: I/O Systems

Systems Architecture II

PC Interrupt Structure and 8259 DMA Controllers

I/O Systems. Jo, Heeseung

INPUT/OUTPUT ORGANIZATION

Chapter 13: I/O Systems

INPUT/OUTPUT ORGANIZATION

Input / Output. School of Computer Science G51CSA

Chapter 13: I/O Systems

Chapter 5 - Input / Output

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)

EE108B Lecture 17 I/O Buses and Interfacing to CPU. Christos Kozyrakis Stanford University

ECE331: Hardware Organization and Design

Example Networks on chip Freescale: MPC Telematics chip

Lecture 15: I/O Devices & Drivers

INPUT-OUTPUT ORGANIZATION

8086 Interrupts and Interrupt Responses:

Chapter 12: I/O Systems

Chapter 13: I/O Systems

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

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University

QUIZ Ch.6. The EAT for a two-level memory is given by:

Operating Systems. V. Input / Output

Unit 1. Chapter 3 Top Level View of Computer Function and Interconnection

CIS Operating Systems I/O Systems & Secondary Storage. Professor Qiang Zeng Fall 2017

Input/Output. Today. Next. Principles of I/O hardware & software I/O software layers Disks. Protection & Security

CS370 Operating Systems

STANDARD I/O INTERFACES

Input Output (IO) Management

Operating Systems. V. Input / Output. Eurecom

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

INPUT/OUTPUT ORGANIZATION

ECE 485/585 Microprocessor System Design

EN1640: Design of Computing Systems Topic 07: I/O

CMSC 313 Lecture 26 DigSim Assignment 3 Cache Memory Virtual Memory + Cache Memory I/O Architecture

CSCI-GA Operating Systems I/O. Hubertus Franke

Programmed I/O Interrupt-Driven I/O Direct Memory Access (DMA) I/O Processors. 10/12/2017 Input/Output Systems and Peripheral Devices (02-2)

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

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

Misc. Third Generation Batch Multiprogramming. Fourth Generation Time Sharing. Last Time Evolution of OSs

4 Multiplexer. Y Fig Keyboard Scan Matrix

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

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

Transcription:

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

Hardware How hardware works Operating system layer What the kernel does API What the programmer does Overview 2

kinds Hardware Block devices: read/write a block independent of all others Disk drive Floppy drive USB pendrive Character devices: read/write one or more bytes Keyboard Mouse Serial Network Printer Miscellaneous Memory-mapped video Video chips Clock 3

Hardware Bus: a set of wires and protocol for communicating ISA PCI USB Memory bus Serial ATA Daisy chain: bus with cables going from one device to the next SCSI Firewire Main Memory Memory Bus PCI Bridge CPU Graphics Controller Monitor Keyboard Mouse USB Universal Serial Bus (USB) PCI Bus Disk Disk SCSI SCSI Bus Level 2 Cache IDE Disk Controller Disk Disk Disk Disk Daisy chain picture from <http://uk.geocities.com/dianne_davies/about-daisies.html> 4

Simple Serial controller has buffer of several bytes Complex SCSI controller Hardware Controllers Reads data from drive serially into block of memory inside controller Returns that block of data once block is completely read 5

Communication between CPU and hardware controller Registers Data in Data out Status Control How to access register? Memory-mapped I/O Registers are in portion of address space Device controller looks for memory accesses in its own area of address space Using I/O ports Separate CPU instructions for reading and writing port address space (Separate bit on the bus specifies I/O space rather than memory space) 6

Communicating with a hardware controller Polling write (busy-wait): CPU: Loop while busy bit in status register is set Set write bit in control register Write data byte into data-out register Set command-ready bit in control register Loop while busy bit in status register is set Controller: Loop while command-ready bit in control register is not set Set busy bit in status register Since write bit in control register is set, read data-out register do I/O Check error Clear command-ready bit in control register Clear error bit in status register Clear busy bit in status register 7

Communicating with a hardware controller Interrupt-driven I/O CPU: Loop while busy bit in status register is set Set write bit in control register Write data byte into data-out register Set command-ready bit in control register Continue processing Controller: Loop while command-ready bit in control register is not set Set busy bit in status register Since write bit in control register is set, read data-out register do I/O Process interrupt Check error Clear command-ready bit in control register Clear error bit in status register Clear busy bit in status register Issue Interrupt 8

Interrupts Interrupt levels Specifies priority of an interrupt; higher-level interrupts are serviced before lower-level ones Non-Maskable Interrupt (NMI) One that the processor cant ignore. Debugging button, for example Interrupt controller will: Be notified by hardware controller that it wishes to interrupt Check to see whether there s an already-pending interrupt of same or higher priority If not, generate interrupt signal to CPU CPU will: Check for interrupt signal after every instruction On interrupt (if not masked), save minimal state Use interrupt vector (table at well-known location) to jump to interrupt-service routine (ISR) ISR will figure out what device caused the interrupt Handle condition that caused the interrupt (wake sleeping process) Restore state by executing return-from-interrupt instruction 9

Without DMA Direct Memory Access (DMA) CPU must transfer information from device controller to main memory (or vice-versa) by reading/writing data one byte/word at a time (programmed I/O) Idea: Have DMA controller that will do the transfer on behalf of the CPU Sometimes built into device controller (must be a bus master) CPU programs the DMA controller to specify source, destination, and amount DMA controller loops: Seize memory bus (cycle stealing) Tell device controller to write to memory address Release memory bus When complete, issue interrupt to CPU Usually used for device generating lots of data Disk, video Not keyboard, for example 10

Layers of I/O software User Space Rest of the process U User-level I/O software Kernel Device-Independent I/O Software IDE Driver Keyboard Driver IDE ISR Keyboard ISR Hardware bus IDE Controller USB Controller disk keyboard 11

Device-driver functionality Initialize Probe whether device is there Figure out interrupt address (usually known by device controller) Allocate data structures Open Install ISR Enable interrupts on controller Close Disable interrupts on controller Uninstall ISR Read Read data from device Write Write data to device ioctl Device-specific functionality (set baud rate, for example) ISR Not called directly but only in response to an interrupt 12

Uniformity Uniform interface between OS and drivers Unix character devices read write open close ioctl Unix block devices (buffered in kernel memory) open close strategy - Given a buffer header with address, read/write bit, block number, word count, major/minor device number 13

Uniformity Uniform interface user programs and devices Unix, for example inode specifies block vs. character and major/minor device numbers - Major number used as index into table of drivers - Minor number used to specify which device which partition on disk which serial port 14

Buffering Unbuffered Driver reads directly into user space, one byte at a time read(fd, &ch, 1) Disadvantage: must wake up user process on every byte Buffered in user space Driver reads directly into a buffer in user space read(fd, buffer, sizeof(buffer)) Disadvantage: must lock the page in memory Buffered in kernel Driver reads into a buffer in the kernel When buffer is full, copied into user space Disadvantage: copying takes time. Buffer may overflow. Double-buffering in kernel Driver reads into a buffer in the kernel When buffer is full, copied to user space While copying (or waiting for user space page to be paged in), use separate buffer for incoming data Disadvantage: more memory used in the kernel 15

Write a network packet Buffering and performance Assemble packet in user space Write Copies to kernel buffer Driver Copies to controller buffer Controller Moves onto network On remote end: Controller Assemble packet into controller buffer Driver Copies from controller buffer to kernel buffer Read Copies from kernel buffer to user space 16

Buffering in user-space User-space I/O software All FILE* routines: fputc, putchar, getchar Formatting routines sprintf, printf, etc. Library interfaces to system calls write Small assembly-language stub that marshals parameters and issues system call Text read etc. Spooling Printing a file 17