© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output mechanisms zInterrupts zMemory management unit (MMU) zCache mechanism.

Slides:



Advertisements
Similar presentations
IO - 1Embedded Systems Lab./Honam University CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
Advertisements

Chapter 3 Basic Input/Output
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
INPUT-OUTPUT ORGANIZATION
Review: Interrupts & Timers
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
Processor System Architecture
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
CS-334: Computer Architecture
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
1 中斷 Interrupt. 2 謂何需要 Interrupt I/O  Busy/wait I/O is very inefficient. CPU can ’ t do other work while testing device. Hard to do simultaneous I/O.
Hierarchy of I/O Control Devices
Interfacing. This Week In DIG II  Basic communications terminology  Communications protocols  Microprocessor interfacing: I/O addressing  Port and.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
Chapter 7 Interupts DMA Channels Context Switching.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors. 1.
Unit-5 CO-MPI autonomous
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
INPUT-OUTPUT ORGANIZATION
Input / Output CS 537 – Introduction to Operating Systems.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 8 Input/Output Basic organization Keyboard input Monitor output Interrupts DMA.
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Introduction to Embedded Systems
CHAPTER 5 I/O PRINCIPLE Understand the principles of System Bus
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Input/Output mechanisms
CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
MICROPROCESSOR INPUT/OUTPUT
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
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,
2009 Sep 10SYSC Dept. Systems and Computer Engineering, Carleton University F09. SYSC2001-Ch7.ppt 1 Chapter 7 Input/Output 7.1 External Devices 7.2.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
Interrupts, Buses Chapter 6.2.5, Introduction to Interrupts Interrupts are a mechanism by which other modules (e.g. I/O) may interrupt normal.
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.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
IT3002 Computer Architecture
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
بسم الله الرحمن الرحيم MEMORY AND I/O.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Lab 2 Microprocessor MPC430F2274 MSP-430 Architecture.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
Lecture 2 Interrupts.
Microprocessor Systems Design I
Computer Architecture
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
I/O Interface and Interrupt Systems
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Interrupt Driven I/O References Text: Tanenbaum ch.1.4.3, ch Receiver Interrupt Program Example:
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Overheads for Computers as Components 2nd ed.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output mechanisms zInterrupts zMemory management unit (MMU) zCache mechanism zCPU performance: Pipelining zCPU power consumption

© 2000 Morgan Kaufman Overheads for Computers as Components I/O devices zUsually includes some non-digital components. zTypical digital interface to CPU: CPU Status/control registers Data registers mechanism Programmable device: e.g., A/D converter bank, serial port, …

© 2000 Morgan Kaufman Overheads for Computers as Components Application: 8251 UART zUniversal asynchronous receiver transmitter (UART): provides serial communication, e.g., serial port connection on PC’s z8251 functions are integrated into a standard PC interface chip. zAllows many communication parameters to be programmed.

© 2000 Morgan Kaufman Overheads for Computers as Components Serial communication zCharacters are transmitted separately: time bit 0bit 1bit n-1 no char Start Bit: 0 Stop bit: 1... One character Period= 1/baud rate

© 2000 Morgan Kaufman Overheads for Computers as Components Serial communication parameters zBaud (bit) rate. zNumber of bits per character: 5-8 zParity/no parity. zEven/odd parity. zLength of stop bit (1, 1.5, 2 bits). zTransmitter/Receiver Ready/Empty: Pin indicating status of Receiver/Transmitter 8251 D0-D7 TxD RxD R/W CS TxRdy RxRdy C/D Control/data Port selection other

© 2000 Morgan Kaufman Overheads for Computers as Components 8251 CPU interface CPU 8251 Status reg (8 bit) Data reg (8 bit) serial port xmit/ rcv

© 2000 Morgan Kaufman Overheads for Computers as Components Programming I/O zTwo ways that microprocessors can support I/O: yspecial-purpose I/O instructions; ymemory-mapped load/store instructions.  Intel x86 provides in, out instructions. Most other CPUs use memory-mapped I/O. zI/O instructions do not preclude memory- mapped I/O, i.e., can use memory map as well.

© 2000 Morgan Kaufman Overheads for Computers as Components ARM memory-mapped I/O zDefine location for device: DEV1 EQU 0x1000 zRead/write code: LDR r1,#DEV1 ; set up device adrs LDR r0,[r1] ; read DEV1 LDR r0,#8 ; set up value to write STR r0,[r1] ; write 8 to device Pseudo-op to define DEV1

© 2000 Morgan Kaufman Overheads for Computers as Components Peek and poke: Use pointers to manipulate I/O zHigh level language interface: int peek(char *location) { return *location; }  #define DEV1 0x1000 int dev_status; dev_status = peek(DEV1); //read device register

© 2000 Morgan Kaufman Overheads for Computers as Components … Peek and poke  void poke(char *location, char newval) { (*location) = newval; }  EXAMPLE: poke (DEV1, 8); //write 8 to device register

© 2000 Morgan Kaufman Overheads for Computers as Components Busy/wait input/output zDevices are typically slower than the CPU: e.g., if we start writing a character before the device has finished with the first one, there may be a problem … z Asking I/O if it has finished by reading a bit in the status register: yBusy waiting on a status bit yPeriodically polling the status bit (with no waiting)

© 2000 Morgan Kaufman Overheads for Computers as Components Example: Write a sequence of characters to an output device  device has status/character registers #define OUT_CHAR 0x1000 //character register address #define OUT_STATUS 0x1001 //status register address char *mystring=``Hello’’; //pointer to a char string char *current_char; /* pointer to current position */ current_char = mystring; while (*current_char != ‘\0’) { poke(OUT_CHAR,*current_char); while (peek(OUT_STATUS)!= 0) ; //1=busy current_char++; }

© 2000 Morgan Kaufman Overheads for Computers as Components Simultaneous busy/wait input and output  Repeatedly read a character from an input device and write it to an output device. #define IN_DATA 0x1000 //define addresses #define IN_STATUS 0x1001 #define OUT_DATA 0x1102 #define OUT_STAT 0x1103 while (TRUE) { /* read */ while (peek(IN_STATUS) == 0) ; achar = (char) peek(IN_DATA); Input device sets IN_STATUS=1 when a new char arrives

© 2000 Morgan Kaufman Overheads for Computers as Components … Simultaneous busy/wait input and output /* write */ poke(OUT_DATA,achar); poke(OUT_STATUS,1); /* turn on device */ /* wait until done */ while (peek(OUT_STATUS) != 0); } /* end of while(TRUE) */

© 2000 Morgan Kaufman Overheads for Computers as Components Interrupt I/O zBusy/wait is very inefficient. yCPU can’t do other work while testing device, e.g., can control other I/O or do computation yHard to do simultaneous I/O. zAlternative: Polling with no busy waiting, interrupts zInterrupts allow a device to change the flow of control in the CPU. yCauses subroutine call to handle device.

© 2000 Morgan Kaufman Overheads for Computers as Components Interrupt interface CPU Control/ status reg data reg mechanism PC intr request intr ack data/address IR Asserted by I/O when it wants service from CPU Asserted by CPU

© 2000 Morgan Kaufman Overheads for Computers as Components Interrupt sequence zDevice asserts interrupt line. zCPU acknowledges request. zCPU calls handler (could be vectored int’pt). zSoftware processes request. zCPU restores state to foreground program.

© 2000 Morgan Kaufman Overheads for Computers as Components Interrupt behavior zBased on subroutine call mechanism. zInterrupt forces next instruction to be a subroutine call to a predetermined location. yReturn address is saved to resume executing foreground program (the program that runs when no interrupt is being handled)

© 2000 Morgan Kaufman Overheads for Computers as Components Interrupt physical interface zCPU and device are connected by CPU bus (Data/Address/Control). zCPU and device handshake: ydevice asserts interrupt request; yCPU asserts interrupt acknowledge when it can handle the interrupt.

© 2000 Morgan Kaufman Overheads for Computers as Components Example: character I/O handlers  Repeatedly read char from input and write it to output char achar; /*for passing to foreground program */ char gotchar; /* signalling a new character */ // Interrupt routine void input_handler() { achar = peek(IN_DATA); /* get char */ gotchar = TRUE; /* signal to main() */ poke(IN_STATUS,0); /* reset status for next transfer */ }

© 2000 Morgan Kaufman Overheads for Computers as Components Example: Interrupt-driven main program main() { while (TRUE) { if (gotchar) { poke(OUT_DATA,achar); gotchar = FALSE; }

© 2000 Morgan Kaufman Overheads for Computers as Components Problems with interrupts zRace conditions int position, velocity; void f1(){ position = peek(POS_DEV_ADDRESS); velocity = peek(VEL_DEV_ADDRESS); } void f2(){ while(1) { plot(position*POS_SCALE_FACTOR); plot(velocity*VEL_SCALE_FAC); } This code is run by a periodic interrupt line (ISR) Running as a main program

© 2000 Morgan Kaufman Overheads for Computers as Components … interrupts zWhat if interrupts are disabled in f2( )?  increases interrupt latency zInterrupt vs polling: Interrupt latency (ex. 60 micro-sec), polling a register (ex. 6 micro-sec)  FAST DEVICE: poll, SLOW DEVICES: interrupt zConvert periodic interrupts to periodic tasks

© 2000 Morgan Kaufman Overheads for Computers as Components Debugging interrupt code- in assembly programming zWhat if you forget to change registers? yForeground program can exhibit mysterious bugs, e.g., if a register is not properly restored in the interrupt handler yBugs will be hard to repeat---depend on interrupt timing.

© 2000 Morgan Kaufman Overheads for Computers as Components Sources of interrupt overhead zHandler execution time. zInterrupt mechanism overhead: branch penalty zRegister save/restore. zPenalties related to the specific architecture: pipeline/cache … zCoding the interrupt handler in assembly may resolve some of the issues, e.g., more efficient use of registers

© 2000 Morgan Kaufman Overheads for Computers as Components ARM interrupts zARM7 supports two types of interrupts: yFast interrupt requests (FIQs): Takes priority over IRQ yInterrupt requests (IRQs). zInterrupt table starts at location 0 (bottom memory address). zInterrupt table contains subroutine calls to appropriate handlers.

© 2000 Morgan Kaufman Overheads for Computers as Components ARM interrupt procedure zCPU actions: ySave PC. Copy CPSR to SPSR (Saved PSR) yForce bits in CPSR to record interrupt. yForce PC to the appropriate interrupt vector. zHandler responsibilities when leaving ISR: yRestore proper PC. yRestore CPSR from SPSR. yClear interrupt disable flags.

© 2000 Morgan Kaufman Overheads for Computers as Components ARM interrupt latency zWorst-case latency to respond to interrupt is 27 cycles zBest interrupt latency: 4 cycles NEXT  CPU & CACHE, MMU