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.

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
ECE 353 Introduction to Microprocessor Systems
Lab III Real-Time Embedded Operating System for a SoC System.
Exceptions. Exception Types Exception Handling Vectoring Interrupts Interrupt Handlers Interrupt Priorities Interrupt applications 6-2.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Interrupts Disclaimer: All diagrams and figures in this presentation are scanned from the book “Microprocessors and Programmed Logic” authored by Kenneth.
I/O Unit.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
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.
Chapter 3 CPUs 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)
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.
Exception Processing ECE511: Digital System & Microprocessor.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
Computer System Organization S H Srinivasan
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Introduction to Interrupts
© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors. 1.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
GURSHARAN SINGH TATLA PIN DIAGRAM OF 8085 GURSHARAN SINGH TATLA
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
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:
Exception and Interrupt Handling
Introduction to Embedded Systems
Embedded Hardware Foundation
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors.
MICROPROCESSOR INPUT/OUTPUT
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output mechanisms zInterrupts zMemory management unit (MMU) zCache mechanism.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
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.
Interrupt Interrupt – to break the flow of speech or action of (someone) by saying or doing something (Longman dictionary)
Interrupts Useful in dealing with: The interface: Random processes;
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.
Chapter 3 Basic Input/Output. Chapter Outline Basic I/O capabilities of computers I/O device interfaces Memory-mapped I/O registers Program-controlled.
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.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
AT91 Interrupt Handling. 2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine.
PPI-8255.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 11.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
 The Programmable Interrupt Controller (PlC) functions as an overall manager in an Interrupt-Driven system. It accepts requests from the peripheral equipment,
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
Multiplex of Data and Address Lines in 8088 Address lines A0-A7 and Data lines D0-D7 are multiplexed in These lines are labelled as AD0-AD7. –By.
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.
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.
Interrupts and exceptions
Timer and Interrupts.
Computer Architecture
Interrupts In 8085 and 8086.
I/O Interface and Interrupt Systems
Subject Name: Microprocessors Subject Code:10EC46 Department: Electronics and Communication Date: /20/2018.
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Overheads for Computers as Components 2nd ed.
X1 & X2 These are also called Crystal Input Pins.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

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.  Interrupts allow a device to change the flow of control in the CPU. Causes subroutine call to handle device.

3 Busy/wait I/O 原理  Simplest way to program device. Use instructions to test when device is ready. current_char = mystring; while (*current_char != ‘\0’) { poke(OUT_CHAR,*current_char); while (peek(OUT_STATUS) != 0); current_char++; }

4 Peek and poke 函式  Traditional HLL interfaces: int peek(char *location) { return *location; } void poke(char *location, char newval) { (*location) = newval; }

5 Interrupt 硬體介面 CPU status reg data reg mechanism PC intr request intr ack data/address IR

6 Interrupt 如何運作  Based on subroutine call mechanism.  Interrupt forces next instruction to be a subroutine call to a predetermined location. Return address is saved to resume executing foreground program.

7 Interrupt physical interface  CPU and device are connected by CPU bus.  CPU and device handshake: device asserts interrupt request; CPU asserts interrupt acknowledge when it can handle the interrupt.

8 Example: character I/O handlers void input_handler() { achar = peek(IN_DATA); gotchar = TRUE; poke(IN_STATUS,0); } void output_handler() { }

9 Example: interrupt-driven main program main() { while (TRUE) { if (gotchar) { poke(OUT_DATA,achar); poke(OUT_STATUS,1); gotchar = FALSE; }

10 Example: interrupt I/O with buffers  Queue for characters: headtail headtail a

11 Buffer-based input handler void input_handler() { char achar; if (full_buffer()) error = 1; else { achar = peek(IN_DATA); add_char(achar); } poke(IN_STATUS,0); if (nchars == 1) { poke(OUT_DATA,remove_char(); poke(OUT_STATUS,1); } }

12 I/O sequence diagram :foreground:input:output:queue empty a b bc c

13 Debugging interrupt code  What if you forget to change registers? Foreground program can exhibit mysterious bugs. Bugs will be hard to repeat---depend on interrupt timing.

14 Priorities and vectors  Two mechanisms allow us to make interrupts more specific: Priorities determine what interrupt gets CPU first. Vectors determine what code is called for each type of interrupt.  Mechanisms are orthogonal: most CPUs provide both.

15 Prioritized interrupts CPU device 1device 2device n L1 L2.. Ln interrupt acknowledge

16 Interrupt prioritization  Masking: interrupt with priority lower than current priority is not recognized until pending interrupt is complete.  Non-maskable interrupt (NMI): highest- priority, never masked. Often used for power-down.

17 Example: Prioritized I/O :interrupts:foreground:A:A:B:B:C:C B A,B C A

18 Interrupt vectors  Allow different devices to be handled by different code.  Interrupt vector table: handler 0 handler 1 handler 2 handler 3 Interrupt vector table head

19 Interrupt vector acquisition :CPU:device receive request receive ack receive vector

20 Generic interrupt mechanism intr? N Y Assume priority selection is handled before this point. N ignore Y ack vector? Y Y N timeout? Y bus error call table[vector] intr priority > current priority? continue execution

21 Interrupt sequence  CPU acknowledges request.  Device sends vector.  CPU calls handler.  Software processes request.  CPU restores state to foreground program.

22 Sources of interrupt overhead  Handler execution time.  Interrupt mechanism overhead.  Register save/restore.  Pipeline-related penalties.  Cache-related penalties.

23 ARM interrupts  ARM7 supports two types of interrupts: Fast interrupt requests (FIQs). Interrupt requests (IRQs).  Interrupt table starts at location 0.

24 ARM interrupt procedure  CPU actions: Save PC. Copy CPSR to SPSR. Force bits in CPSR to record interrupt. Force PC to vector.  Handler responsibilities: Restore proper PC. Restore CPSR from SPSR. Clear interrupt disable flags.

25 ARM interrupt latency  Worst-case latency to respond to interrupt is 27 cycles: Two cycles to synchronize external request. Up to 20 cycles to complete current instruction. Three cycles for data abort. Two cycles to enter interrupt handling state.

26 Supervisor mode  May want to provide protective barriers between programs. Avoid memory corruption.  Need supervisor mode to manage the various programs.  Some low end CPUs do not have a supervisor mode.

27 ARM supervisor mode  Use SWI instruction to enter supervisor mode, similar to subroutine: SWI CODE_1  Sets PC to 0x08.  Argument to SWI is passed to supervisor mode code.  Saves CPSR in SPSR.

28 Exception  Exception: internally detected error.  Exceptions are synchronous with instructions but unpredictable.  Build exception mechanism on top of interrupt mechanism.  Exceptions are usually prioritized and vectorized.

29 Trap  Trap (software interrupt): an exception generated by an instruction. Call supervisor mode.  ARM uses SWI instruction for traps.  SHARC offers three levels of software interrupts. Called by setting bits in IRPTL register.