CS 61C L39 I/O (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.

Slides:



Advertisements
Similar presentations
Memory Mapped I/O. What is Memory Mapped I/O? Instead of having special methods for accessing the values to be read or written, just get them from memory.
Advertisements

Input and Output CS 215 Lecture #20.
Pipelining II (1) Fall 2005 Lecture 19: Pipelining II.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
CS61C L27 I/O & Networks (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #27 I/O.
EE30332 Ch8 DP – 1 Ch 8 Interfacing Processors and Peripherals Buses °Fundamental tool for designing and building computer systems divide the problem into.
CS61C L29 CPU Design : Pipelining to Improve Performance II (1) Garcia, Fall 2006 © UCB Running away with it  Our #8 football team had a great effort.
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 36: IO Basics Instructor: Dan Garcia
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 29 – CPU Design : Pipelining to Improve Performance II Designed for the.
CS Computer Architecture 1 CS 430 – Computer Architecture Pipelined Execution - Review William J. Taffe using slides of David Patterson.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 29 – CPU Design : Pipelining to Improve Performance II Cal researcher Marty.
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.
CS61C L24 Introduction to CPU Design (1) Garcia, Spring 2007 © UCB Cell pic to web site  A new MS app lets people search the web based on a digital cell.
CS 430 – Computer Architecture 1 CS 430 – Computer Architecture Input/Output: Polling and Interrupts William J. Taffe using the slides of David Patterson.
CS61C L30 CPU Design : Pipelining to Improve Performance II (1) Garcia, Spring 2007 © UCB E-voting bill in congress!  Rep Rush Holt (D-NJ) has a bill.
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.
CS61C L18 Introduction to CPU Design (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture.
CS61C L31 Caches I (1) Garcia 2005 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
CS61C L30 Caches I (1) Garcia, Fall 2006 © UCB Shuttle can’t fly over Jan 1?  A computer bug has come up for the shuttle – its computers don’t reset to.
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.
CS61C L13 I/O © UC Regents 1 CS61C - Machine Structures Lecture 13 - Input/Output: Polling and Interrupts October 11, 2000 David Patterson
CS61C L24 Introduction to CPU Design (1) Garcia, Fall 2006 © UCB Fedora Core 6 (FC6) just out  The latest version of the distro has been released; they.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 24 Introduction to CPU design Stanford researchers developing 3D camera.
CS 61C L20 Introduction to Synchronous Digital Systems (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS61C L31 Pipelined Execution, part II (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS61C L31 Caches I (1) Garcia, Spring 2007 © UCB Powerpoint bad!!  Research done at the Univ of NSW says that “working memory”, the brain part providing.
CS61C L37 I/O (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture.
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 L30 Introduction to Pipelined Execution (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS 61C L38 Pipelined Execution, part II (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Instructor: Justin Hsia CS 61C: Great Ideas in Computer Architecture Input/Output 8/12/20131Summer Lecture #28.
CS 61C: Great Ideas in Computer Architecture Lecture 22: Operating Systems, Interrupts, and Virtual Memory Part 1 Instructor: Sagar Karandikar
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Operating Systems, Interrupts, Virtual Memory Instructors: Krste Asanovic & Vladimir.
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
Input and Output Computer Organization and Assembly Language: Module 9.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
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,
CS 61C L6.2.2 Interrupts (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Interrupts Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
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.
CS2100 Computer Organisation Input/Output – Own reading only (AY2015/6) Semester 1 Adapted from David Patternson’s lecture slides:
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Operating Systems, Interrupts, Virtual Memory Instructors: John Wawrzynek & Vladimir.
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.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Instructor: Senior Lecturer SOE Dan Garcia CS 61C: Great Ideas in Computer Architecture Pipelining Hazards 1.
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.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
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.
Operating Systems (CS 340 D)
Inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 35 – Input / Output Lecturer SOE Dan Garcia
Chapter 8 I/O.
Instructors: Yuanqing Cheng
Operating Systems Chapter 5: Input/Output Management
Chapter 8 I/O.
Interrupts and Exception Handling
Lecturer PSOE Dan Garcia
Chapter 8 I/O.
Lectures 9-1: I/O Interfacing
CS61C - Machine Structures Lecture 14 - Input/Output
Interrupts and Exception Handling
Presentation transcript:

CS 61C L39 I/O (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 39 – Input / Output Bugatti Veyron!  1,001Hp! 250 mph! Zero-to-60 in 3 seconds. Zero-to-180 in 14 seconds. $1 Million price tag. Fastest and most expensive production car!

CS 61C L39 I/O (2) Garcia, Spring 2004 © UCB Review Pipeline challenge is hazards Forwarding helps w/many data hazards Delayed branch helps with control hazard in 5 stage pipeline Filling the load & branch delay slots is an important job of compilers More aggressive performance: Out-of-order execution Superscalar (task mix nec to utilize resources)

CS 61C L39 I/O (3) Garcia, Spring 2004 © UCB Peer Instruction Assume 1 instr/clock, delayed branch, 5 stage pipeline, forwarding, interlock on unresolved load hazards (after 10 3 loops, so pipeline full) Loop:lw $t0, 0($s1) addu $t0, $t0, $s2 sw $t0, 0($s1) addiu $s1, $s1, -4 bne $s1, $zero, Loop nop How many pipeline stages (clock cycles) per loop iteration to execute this code?

CS 61C L39 I/O (4) Garcia, Spring 2004 © UCB Peer Instruction Assume 1 instr/clock, delayed branch, 5 stage pipeline, forwarding, interlock on unresolved load hazards iterations, so pipeline full. Loop:lw$t0, 0($s1) addu$t0, $t0, $s2 sw$t0, 0($s1) addiu$s1, $s1, -4 bne$s1, $zero, Loop nop How many pipeline stages (clock cycles) per loop iteration to execute this code? (data hazard so stall) (delayed branch so exec. nop)

CS 61C L39 I/O (5) Garcia, Spring 2004 © UCB Recall : 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, Network Earlier LecturesCurrent Lectures

CS 61C L39 I/O (6) Garcia, Spring 2004 © UCB Motivation for Input/Output I/O is how humans interact with computers I/O gives computers long-term memory. 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) Computer without I/O like a car without wheels; great technology, but won’t get you anywhere

CS 61C L39 I/O (7) Garcia, Spring 2004 © UCB I/O Device Examples and Speeds I/O Speed: bytes transferred per second (from mouse to Gigabit LAN: 100-million-to-1) DeviceBehaviorPartner Data Rate (KBytes/s) KeyboardInputHuman0.01 MouseInputHuman0.02 Voice outputOutputHuman5.00 Floppy diskStorageMachine50.00 Laser PrinterOutputHuman Magnetic DiskStorageMachine10, Wireless NetworkI or OMachine 10, Graphics DisplayOutputHuman30, Wired LAN NetworkI or OMachine1,000,000.00

CS 61C L39 I/O (8) Garcia, Spring 2004 © UCB What do we need to make I/O work? A way to present them to user programs so they are useful cmd reg. data reg. Operating System APIsFiles Proc Mem A way to connect many types of devices to the Proc-Mem PCI Bus SCSI Bus A way to control these devices, respond to them, and transfer data

CS 61C L39 I/O (9) Garcia, Spring 2004 © UCB Instruction Set Architecture for I/O What must the processor do for I/O? Input: reads a sequence of bytes Output: writes a sequence of bytes Some processors have special input and output instructions Alternative model (used by MIPS): 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 L39 I/O (10) Garcia, Spring 2004 © UCB Memory Mapped I/O Certain addresses are not regular memory Instead, they correspond to registers in I/O devices cntrl reg. data reg. 0 0xFFFFFFFF 0xFFFF0000 address

CS 61C L39 I/O (11) Garcia, Spring 2004 © UCB Processor-I/O Speed Mismatch 1GHz microprocessor can execute 1 billion load or store instructions per second, or 4,000,000 KB/s data rate I/O devices data rates range from 0.01 KB/s to 1,000,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 not be ready to accept data as fast as processor stores it What to do?

CS 61C L39 I/O (12) Garcia, Spring 2004 © UCB Processor Checks Status before Acting Path to device generally has 2 registers: Control Register, says it’s OK to read/write (I/O ready) [think of a flagman on a road] Data Register, contains data Processor reads from Control Register in loop, waiting for device to set Ready bit in Control reg (0  1) to say its OK Processor then loads from (input) or writes to (output) data register Load from or Store into Data Register resets Ready bit (1  0) of Control Register

CS 61C L39 I/O (13) Garcia, Spring 2004 © 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 L39 I/O (14) Garcia, Spring 2004 © UCB SPIM I/O Control register rightmost bit (0): Ready 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. bit 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 L39 I/O (15) Garcia, Spring 2004 © UCB I/O Example Input: Read from keyboard into $v0 lui$t0, 0xffff #ffff0000 Waitloop:lw$t1, 0($t0) #control andi$t1,$t1,0x1 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,0x1 beq$t1,$zero, Waitloop sw$a0, 12($t0) #data Processor waiting for I/O called “Polling”

CS 61C L39 I/O (16) Garcia, Spring 2004 © UCB Administrivia Only 5 lectures to go (after this one)! :(

CS 61C L39 I/O (17) Garcia, Spring 2004 © UCB Cost of Polling? Assume for a processor with a 1GHz 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 16 MB/second. Again, no transfer can be missed.

CS 61C L39 I/O (18) Garcia, Spring 2004 © UCB % Processor time to poll [p. 677 in book] Mouse Polling, Clocks/sec = 30 [polls/s] * 400 [clocks/poll] = 12K [clocks/s] % Processor for polling: 12*10 3 [clocks/s] / 1*10 9 [clocks/s] = %  Polling mouse little impact on processor Frequency of Polling Floppy = 50 [KB/s] / 2 [B/poll] = 25K [polls/s] Floppy Polling, Clocks/sec = 25K [polls/s] * 400 [clocks/poll] = 10M [clocks/s] % Processor for polling: 10*10 6 [clocks/s] / 1*10 9 [clocks/s] = 1%  OK if not too many I/O devices

CS 61C L39 I/O (19) Garcia, Spring 2004 © UCB % Processor time to poll hard disk Frequency of Polling Disk = 16 [MB/s] / 16 [B] = 1M [polls/s] Disk Polling, Clocks/sec = 1M [polls/s] * 400 [clocks/poll] = 400M [clocks/s] % Processor for polling: 400*10 6 [clocks/s] / 1*10 9 [clocks/s] = 40%  Unacceptable

CS 61C L39 I/O (20) Garcia, Spring 2004 © UCB What is the alternative to polling? Wasteful to have processor spend most of its time “spin-waiting” for I/O to be ready Would like an unplanned procedure call that would be invoked only when I/O device is ready Solution: use exception mechanism to help I/O. Interrupt program when I/O ready, return when done with data transfer

CS 61C L39 I/O (21) Garcia, Spring 2004 © UCB I/O Interrupt An I/O interrupt is like overflow 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, but it can happen in the middle of any given instruction I/O interrupt does not prevent any instruction from completion

CS 61C L39 I/O (22) Garcia, Spring 2004 © UCB Definitions for Clarification Exception: signal marking that something “out of the ordinary” has happened and needs to be handled Interrupt: asynchronous exception Trap: synchronous exception Note: These are different from the book’s definitions.

CS 61C L39 I/O (23) Garcia, Spring 2004 © UCB Interrupt Driven Data Transfer (1) I/O interrupt (2) save PC Memory add sub and or user program read store... jr interrupt service routine (3) jump to interrupt service routine (4) perform transfer (5)

CS 61C L39 I/O (24) Garcia, Spring 2004 © 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 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 L39 I/O (25) Garcia, Spring 2004 © UCB Benefit of Interrupt-Driven I/O Find the % of processor consumed if the hard disk is only active 5% of the time. Assuming 500 clock cycle overhead for each transfer, including interrupt: Disk Interrupts/s = 16 MB/s / 16B/interrupt = 1M interrupts/s Disk Interrupts, clocks/s = 1M interrupts/s * 500 clocks/interrupt = 500,000,000 clocks/s % Processor for during transfer: 500*10 6 / 1*10 9 = 50% Disk active 5%  5% * 50%  2.5% busy

CS 61C L39 I/O (26) Garcia, Spring 2004 © UCB Peer Instruction A. A faster CPU will result in faster I/O. B. Hardware designers handle mouse input with interrupts since it is better than polling in almost all cases. C. Low-level I/O is actually quite simple, as it’s really only reading and writing bytes. ABC 1: FFF 2: FFT 3: FTF 4: FTT 5: TFF 6: TFT 7: TTF 8: TTT

CS 61C L39 I/O (27) Garcia, Spring 2004 © UCB Peer Instruction Answer A. A faster CPU will result in faster I/O. B. Hardware designers handle mouse input with interrupts since it is better than polling in almost all cases. C. Low-level I/O is actually quite simple, as it’s really only reading and writing bytes. ABC 1: FFF 2: FFT 3: FTF 4: FTT 5: TFF 6: TFT 7: TTF 8: TTT F A L S E T R U E A. Less sync data idle time B. Because mouse has low I/O rate polling often used C. Concurrency, device requirements vary! F A L S E

CS 61C L39 I/O (28) Garcia, Spring 2004 © UCB “And in conclusion…” I/O gives computers their 5 senses I/O speed range is 100-million to one Processor speed means must synchronize with I/O devices before use Polling works, but expensive processor repeatedly queries devices Interrupts works, more complex devices causes an exception, causing OS to run and deal with the device I/O control leads to Operating Systems