Cs 61C L12 I/O.1 Patterson Spring 99 ©UCB CS61C Input/Output Lecture 12 February 26, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html.

Slides:



Advertisements
Similar presentations
1 IKI20210 Pengantar Organisasi Komputer Kuliah No. 19: I/O, Interupsi 20 November 2002 Bobby Nazief Johny Moningka
Advertisements

Input and Output CS 215 Lecture #20.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
EE30332 Ch8 DP – 1 Ch 8 Interfacing Processors and Peripherals Buses °Fundamental tool for designing and building computer systems divide the problem into.
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 36: IO Basics Instructor: Dan Garcia
CS61C L36 Input / Output (1) Garcia, Spring 2007 © UCB Robson disk $  Intel has a NAND flash-based disk cache which can speed up access for laptops and.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 34 – Input / Output “Arduino is an open-source electronics prototyping.
CS 430 – Computer Architecture 1 CS 430 – Computer Architecture Input/Output: Polling and Interrupts William J. Taffe using the slides of David Patterson.
CS61C L25 I/O (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #25: I/O Andy Carle.
Chapter 8 I/O. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-2 I/O: Connecting to Outside World So far,
CS61C L24 Input/Output, Networks I (1) Garcia, Fall 2005 © UCB Lecturer PSOE, new dad Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS61C L26 Virtual Memory II (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #26.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
CS61C L13 I/O © UC Regents 1 CS61C - Machine Structures Lecture 13 - Input/Output: Polling and Interrupts October 11, 2000 David Patterson
CS 61C L39 I/O (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
CS61C L37 I/O (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
INPUT-OUTPUT ORGANIZATION
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
MIPS I/O and Interrupt. SPIM I/O and MIPS Interrupts The materials of this lecture can be found in A7-A8 (3 rd Edition) and B7-B8 (4 th Edition).
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
Chapter 1. Introduction What is an Operating System? Mainframe Systems
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Input and Output Computer Organization and Assembly Language: Module 9.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
Chapter 8 I/O. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-2 I/O: Connecting to Outside World So far,
MIPS I/O and Interrupt. .data val1:.float 0.6 val2:.float 0.8 msg_done:.asciiz "done\n".text.globl main main: li.s $f0, mfc1 $a0, $f0 jal calsqrt.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
CH10 Input/Output DDDData Transfer EEEExternal Devices IIII/O Modules PPPProgrammed I/O IIIInterrupt-Driven I/O DDDDirect Memory.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
MIPS I/O and Interrupt.
CS2100 Computer Organisation Input/Output – Own reading only (AY2015/6) Semester 1 Adapted from David Patternson’s lecture slides:
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 37: IO Basics Instructor: Dan Garcia
Adapted from Computer Organization and Design, Patterson & Hennessy ECE232: Hardware Organization and Design Part 17: Input/Output Chapter 6
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Lecture on Central Process Unit (CPU)
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
10/15: Lecture Topics Input/Output –Types of I/O Devices –How devices communicate with the rest of the system communicating with the processor communicating.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Chapter 8 Input/Output An Hong 2015 Fall School of Computer Science and Technology Lecture on Introduction to.
CS 110 Computer Architecture Lecture 22: Operating Systems, Interrupts, Virtual Memory Instructor: Sören Schwertfeger School.
Chapter 8 I/O.
MIPS I/O and Interrupt.
Inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 35 – Input / Output Lecturer SOE Dan Garcia
Some of the slides are adopted from Prof. David Patterson (UCB)
CS703 - Advanced Operating Systems
Chapter 8 I/O.
MIPS I/O and Interrupt.
Computer Architecture
MIPS I/O and Interrupt.
Chapter 8 I/O.
Chapter 8 I/O.
Interrupts and Exception Handling
MIPS I/O and Interrupt.
Chapter 8 I/O.
Lectures 9-1: I/O Interfacing
CS61C - Machine Structures Lecture 14 - Input/Output
Interrupts and Exception Handling
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:

cs 61C L12 I/O.1 Patterson Spring 99 ©UCB CS61C Input/Output Lecture 12 February 26, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html

cs 61C L12 I/O.2 Patterson Spring 99 ©UCB “Review..” 1/1 °Pointer is high level language version of address Powerful yet dangerous concept °Like goto, with self-imposed discipline can achieve clarity and simplicity Also can cause difficult to fix bugs °C supports pointers, pointer arithmetic °Java structure pointers have many of the same potential problems!

cs 61C L12 I/O.3 Patterson Spring 99 ©UCB Outline °Input/Output (I/O) Motivation and Speed °Instruction set support for I/O °Synchronizing Processor and I/O devices °Polling to synchronize °Administrivia, “Computers in the News” °Example I/O interface: SPIM °Weaknesses of Polling °Interrupts to synchronize °Conclusion

cs 61C L12 I/O.4 Patterson Spring 99 ©UCB Anatomy: 5 components of any Computer Processor (active) Computer Control (“brain”) Datapath (“brawn”) Memory (passive) (where programs, data live when running) Devices Input Output Keyboard, Mouse Display, Printer Disk (where programs, data live when not running) Lectures 1-11Lectures 12-14

cs 61C L12 I/O.5 Patterson Spring 99 ©UCB Motivation for Input/Output °I/O is how humans interact with computers °I/O lets computers do amazing things: Read pressure of synthetic hand and control synthetic arm and hand of fireman Control propellers, fins, communicate in BOB (Breathable Observable Bubble) Read bar codes of items in refrigerator °Computer without I/O like a car without wheels; great technology, but won’t get you anywhere

cs 61C L12 I/O.6 Patterson Spring 99 ©UCB I/O Device Examples and Speeds °I/O Speed: bytes transferred per second (from mouse to display: million-to-1) °DeviceBehaviorPartner Data Rate (Kbytes/sec) KeyboardInputHuman0.01 MouseInputHuman0.02 Line PrinterOutputHuman1.00 Floppy diskStorageMachine50.00 Laser PrinterOutputHuman Optical DiskStorageMachine Magnetic DiskStorageMachine10, Network-LANI or OMachine 10, Graphics DisplayOutputHuman30,000.00

cs 61C L12 I/O.7 Patterson Spring 99 ©UCB Instruction Set Architecture for I/O °Some machines have special input and output instructions °Alternative model (used by MIPS): Input: ~ reads a sequence of bytes Output: ~ writes a sequence of bytes °Memory also a sequence of bytes, so use loads for input, stores for output Called “Memory Mapped Input/Output” A portion of the address space dedicated to communication paths to Input or Output devices (no memory there)

cs 61C L12 I/O.8 Patterson Spring 99 ©UCB Processor-I/O Speed Mismatch °500 MHz microprocessor can execute a 500 million load or store instructions per second, or 200,000 KB/s data rate I/O devices from 0.01 KB/s to 30,000 KB/s °Input: device may not be ready to send data as fast as the processor loads it Also, might be waiting for human to act °Output: device may not be ready to accept data as fast as processor stores it °What to do?

cs 61C L12 I/O.9 Patterson Spring 99 ©UCB Processor Checks Status before Acting °Path to device generally has 2 registers: 1 register says its OK to read/write (I/O ready), often called Control Register 1 register to contain data, often called Data Register °Processor reads from Control Register in loop, waiting for device to set Ready bit in Control reg to say its OK (0  1) °Processor then loads from (input) or writes to (output) data register Load from device/Store into Data Register resets Ready bit (1  0) of Control Register

cs 61C L12 I/O.10 Patterson Spring 99 ©UCB SPIM I/O Simulation °SPIM simulates 1 I/O device: memory- mapped terminal (keyboard + display) Read from keyboard (receiver); 2 device regs Writes to terminal (transmitter); 2 device regs Received Byte Receiver Data 0xffff0004 Unused ( ) (IE)Receiver Control 0xffff0000 Ready (I.E.) Unused ( ) Transmitted Byte Transmitter Control 0xffff0008 Transmitter Data 0xffff000c Ready (I.E.) Unused ( ) Unused

cs 61C L12 I/O.11 Patterson Spring 99 ©UCB SPIM I/O °Control register rightmost bit (0): Ready It cannot be changed by processor (like $0) Receiver: Ready==1 means character in Data Register not yet been read; 1  0 when data is read from Data Reg Transmitter: Ready==1 means transmitter is ready to accept a new character; 0  Transmitter still busy writing last char -(I.E. discussed later) °Data register rightmost byte has data Receiver: last char from keyboard; rest = 0 Transmitter: when write rightmost byte, writes char to display

cs 61C L12 I/O.12 Patterson Spring 99 ©UCB I/O Example °Input: Read from keyboard into $v0 lui$t0, 0xffff # ffff0000 Waitloop:lw$t1, 0($t0) #control andi$t1,$t1,0x0001 beq$t1,$zero, Waitloop lw$v0, 4($t0) # data °Output: Write to display from $a0 lui$t0, 0xffff # ffff0000 Waitloop:lw$t1, 8($t0) #control andi$t1,$t1,0x0001 beq$t1,$zero, Waitloop sw$a0, 12($t0) # data °Processor waiting for I/O called “Polling”

cs 61C L12 I/O.13 Patterson Spring 99 ©UCB Administrivia °Readings: Pointers: COD: 3.11, K&R Ch. 5; I/O 8.3, 8.5, A.7, A.8 °6th homework: Due 3/3 7PM Exercises 8.1, 8.5, 8.8 °3rd Project/5th Lab: MIPS Simulator Due Wed. 3/3 7PM; deadline Thurs 8AM °Upcoming events Midterm on 3/17 5pm-8PM, 1 Pimentel 4th Project due same day as midterm???  4th Project due Wed. 3/10 2nd online questionnaire when demo 6th lab

cs 61C L12 I/O.14 Patterson Spring 99 ©UCB “Computers in the News” °“Intel Demonstrates Performance of New Pentium Microprocessor”, NY Times, 2/24/99 Intel has tried to position the Pentium III as a “next generation”microprocessor, but industry analysts have generally viewed the 500-MHz chip as merely an incremental advance over the company's 450-MHz Pentium II chips. [In past Intel been closing in on RISC chips.] “If you are just running the same old software it doesn't do much for you,” an analyst said. “It’s a little faster than the Pentium II 450.” Pentium III has additional instructions that offer faster processing of three-dimensional graphics for games, speech recognition processing and video compression.[software?]

cs 61C L12 I/O.15 Patterson Spring 99 ©UCB Cost of Polling? °Assume for a processor with a 500-MHz clock it takes 400 clock cycles for a polling operation (call polling routine, accessing the device, and returning). Determine % of processor time for polling Mouse: polled 30 times/sec so as not to miss user movement Floppy disk: transfers data in 2-byte units and has a data rate of 50 KB/second. No data transfer can be missed. “Hard” disk: transfers data in 16-byte chunks and can transfer at 8 MB/second. Again, no transfer can be missed.

cs 61C L12 I/O.16 Patterson Spring 99 ©UCB % Processor time to poll mouse, floppy °Mouse Polling Clocks/sec = 30 * 400 = clocks/sec °% Processor for polling: 12*10 3 /500*10 6 = 0.002%  Polling mouse little impact on processor °Times Polling Floppy/sec = 50 KB/s /2B = 25K polls/sec °Floppy Polling Clocks/sec = 25K * 400 = 10,000,000 clocks/sec °% Processor for polling: 10*10 6 /500*10 6 = 2%  OK if not too many I/O devices

cs 61C L12 I/O.17 Patterson Spring 99 ©UCB % Processor time to hard disk °Times Polling Disk/sec = 8 MB/s /16B = 500K polls/sec °Disk Polling Clocks/sec = 500K * 400 = 200,000,000 clocks/sec °% Processor for polling: 200*10 6 /500*10 6 = 40%  Unacceptable

cs 61C L12 I/O.18 Patterson Spring 99 ©UCB What is the alternative to polling? °Wasteful to have processor spend most of its time “spin-waiting” for I/O to be ready °Wish we could have an unplanned procedure call that would be invoked only when I/O device is ready °Sounds familiar? °Use exception mechanism for arithmetic overflow to help I/O: interrupt program when I/O ready, return when done with data transfer

cs 61C L12 I/O.19 Patterson Spring 99 ©UCB I/O Interrupt °An I/O interrupt is just like the exceptions except: An I/O interrupt is “asynchronous” More information needs to be conveyed °An I/O interrupt is asynchronous with respect to instruction execution: I/O interrupt is not associated with any instruction I/O interrupt does not prevent any instruction from completion -Pick convenient point to take an interrupt

cs 61C L12 I/O.20 Patterson Spring 99 ©UCB Interrupt Driven Data Transfer (1) I/O interrupt (2) save PC (3) interrupt service addr add sub and or read store... jr Memory user program interrupt service routine (4) (5)

cs 61C L12 I/O.21 Patterson Spring 99 ©UCB Instruction Set support for I/O Interrupt °Save the PC for return? Exception Program Counter, like overflow °Where go when interrupt occurs? MIPS defines location: 0x °Determine cause of interrupt? MIPS has Cause Register, 4-bit field (bits 5 to 2) gives cause of exception

cs 61C L12 I/O.22 Patterson Spring 99 ©UCB Instruction Set support for I/O Interrupt °Portion of MIPS architecture for interrupts called “coprocessor 0” °Coprocessor 0 Instructions Data transfer: lwc0, swc0 Move: mfc0, mtc0 °Coprocessor 0 Registers: name number usage BadVAddr $8 Bad memory address Status $12 Interrupt enable Cause $13 Exception type EPC $14 Instruction address

cs 61C L12 I/O.23 Patterson Spring 99 ©UCB SPIM I/O Simulation: Interrupt Driven I/O °I.E. stands for Interrupt Enable °Set Interrupt Enable bit to 1 have interrupt occur whenever Ready bit is set Received Byte Transmitted Byte (IE)Receiver Control 0xffff0000 Transmitter Control 0xffff0008 Transmitter Data 0xffff000c Receiver Data 0xffff0004 Ready (I.E.) Ready (I.E.) Unused ( ) Unused

cs 61C L12 I/O.24 Patterson Spring 99 ©UCB Example Interrupt Routine °Place at 0x text 0c mfc0$k0, $13 # $13 is Cause reg mfc0$k1, $14 # $14 is EPC reg Why don’t have to save $k0, $k1? °Exception field is bits 5 to 2; 0  I/O andi$k0,$k0,0x003c # select 5-2 bne$k0,$zero, OtherException °Read byte sw$ra, save0($0) # save old $31 jalReadandStoreByte lw$ra, save0($0) # restore $31 jr$k1

cs 61C L12 I/O.25 Patterson Spring 99 ©UCB Benefit of Interrupt-Driven I/O °500 clock cycle overhead for each transfer, including interrupt. Find the % of processor consumed if the hard disk is only active 5% of the time. °Interrupt rate = polling rate Disk Interrupts/sec = 8 MB/s /16B = 500K interrupts/sec Disk Polling Clocks/sec = 500K * 500 = 250,000,000 clocks/sec % Processor for during transfer: 250*10 6 /500*10 6 = 50% °Disk active 5%  5% * 50%  2.5% busy

cs 61C L12 I/O.26 Patterson Spring 99 ©UCB Questions Raised about Interrupts °Which I/O device caused exception? Needs to convey the identity of the device generating the interrupt °Can avoid interrupts during the interrupt routine? What if more important interrupt occurs while servicing this interrupt? Allow interrupt routine to be enterred again? °Who keeps track of status of all the devices, handle errors, know where to put/supply the I/O data?

cs 61C L12 I/O.27 Patterson Spring 99 ©UCB 4 Responsibilities leading to OS °The I/O system is shared by multiple programs using the processor °Low-level control of I/O device is complex because requires managing a set of concurrent events and because requirements for correct device control are often very detailed °I/O systems often use interrupts to communicate information about I/O operations °Would like I/O services for all user programs, under safe control

cs 61C L12 I/O.28 Patterson Spring 99 ©UCB 4 Functions OS must provide °OS guarantees that user’s program accesses only the portions of I/O device to which user has rights (e.g., file access) °OS provides abstractions for accessing devices by supplying routines that handle low-level device operations °OS handles the interrupts generated by I/O devices, (and arithmetic exceptions generated by a program) °OS tries to provide equitable access to the shared I/O resources, as well as schedule accesses in order to enhance system performance

cs 61C L12 I/O.29 Patterson Spring 99 ©UCB History °6550 editing minutes at start, Rev 689 °Th 9:39AM, Rev 690, 6605 min °Th 5:58PM, Rev 694, 6667 min °Th 10:44PM, Rev 734, 6894 min °Fri 7:35 AM, Rev 739, 6935 min °385 minutes so far + reading material °/ 28 slides = minutes/slide