Interrupts Peter Rounce - room 6.18

Similar documents
Interrupts Peter Rounce

Input / Output. School of Computer Science G51CSA

Operating System Control Structures

Input Output (IO) Management

CPS104 Computer Organization and Programming Lecture 17: Interrupts and Exceptions. Interrupts Exceptions and Traps. Visualizing an Interrupt

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

CSC227: Operating Systems Fall Chapter 1 INTERRUPTS. Dr. Soha S. Zaghloul

18-349: Introduction to Embedded Real-Time Systems

PC Interrupt Structure and 8259 DMA Controllers

Q.1 Explain Computer s Basic Elements

Computer System Overview. Chapter 1

Process Description and Control. Major Requirements of an Operating System

Major Requirements of an Operating System Process Description and Control

These three counters can be programmed for either binary or BCD count.

Process Description and Control

ECE332, Week 8. Topics. October 15, Exceptions. Hardware Interrupts Software exceptions

There are different characteristics for exceptions. They are as follows:

Virtual Memory Outline

Process Description and Control. Chapter 3

Computer System Overview

Computer System Overview

Major Requirements of an OS

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

Efficiency and memory footprint of Xilkernel for the Microblaze soft processor

Process Description and Control

Chapter 9: Virtual Memory

8086 Interrupts and Interrupt Responses:

Lecture 3: Concurrency & Tasking

Operating Systems. Lecture 3- Process Description and Control. Masood Niazi Torshiz

OPERATING SYSTEMS. Systems with Multi-programming. CS 3502 Spring Chapter 4

Unit 3 and Unit 4: Chapter 4 INPUT/OUTPUT ORGANIZATION

Process Context & Interrupts. New process can mess up information in old process. (i.e. what if they both use the same register?)

Module 3. Embedded Systems I/O. Version 2 EE IIT, Kharagpur 1

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

Page Replacement Algorithms

CoE3DJ4 Digital Systems Design. Chapter 6: Interrupts

1. Background. 2. Demand Paging

Inf2C - Computer Systems Lecture 16 Exceptions and Processor Management

Interrupts in Zynq Systems

CHAPTER 11 INTERRUPTS PROGRAMMING

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

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

Single thread Scheduler All processes called once each sample

GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III

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

3.1 Introduction. Computers perform operations concurrently

Chapter 9: Virtual-Memory

Real-Time Programming

Process- Concept &Process Scheduling OPERATING SYSTEMS

4) In response to the the 8259A sets the highest priority ISR, bit and reset the corresponding IRR bit. The 8259A also places

Chapter 8: Virtual Memory. Operating System Concepts

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Embedded Software TI2726 B. 4. Interrupts. Koen Langendoen. Embedded Software Group

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

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

INPUT/OUTPUT ORGANIZATION

Silberschatz and Galvin Chapter 12

Design and Implementation Interrupt Mechanism

Today s class. Finish review of C Process description and control. Informationsteknologi. Tuesday, September 18, 2007

Interrupt/Timer/DMA 1

Chapter 3 - Top Level View of Computer Function

IT 540 Operating Systems ECE519 Advanced Operating Systems

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Topics. Interfacing chips

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

CS 550 Operating Systems Spring Interrupt

Module 12: I/O Systems

Introduction to general architectures of 8 and 16 bit micro-processor and micro-controllers

8051 Interrupt Organization

8051 Microcontroller memory Organization and its Applications

CS370 Operating Systems

UNIT- 5. Chapter 12 Processor Structure and Function

In examining performance Interested in several things Exact times if computable Bounded times if exact not computable Can be measured

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

I/O - input/output. system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices. CPU Cache

INTERRUPTS in microprocessor systems

Process Scheduling Queues

Tasks. Task Implementation and management

Interrupts. by Rahul Patel, Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar

Chapter 09. Programming in Assembly

The Operating System (OS) MicroComputer Engineering OperatingSystem slide 1!

Programming Embedded Systems

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

The K Project. Interrupt and Exception Handling. LSE Team. May 14, 2018 EPITA. The K Project. LSE Team. Introduction. Interrupt Descriptor Table

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

CS 104 Computer Organization and Design

INPUT/OUTPUT ORGANIZATION

Memory Organization MEMORY ORGANIZATION. Memory Hierarchy. Main Memory. Auxiliary Memory. Associative Memory. Cache Memory.

MP Assignment III. 1. An 8255A installed in a system has system base address E0D0H.

Systems Architecture II


Hardware OS & OS- Application interface

Chapter 1 Computer System Overview

Anne Bracy CS 3410 Computer Science Cornell University

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1

EE458 - Embedded Systems Exceptions and Interrupts

[08] IO SUBSYSTEM 1. 1

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

ECE 372 Microcontroller Design Parallel IO Ports - Interrupts. ECE 372 Microcontroller Design Parallel IO Ports - Interrupts

Transcription:

Interrupts Peter Rounce - room 6.18 P.Rounce@cs.ucl.ac.uk 20/11/2006 1001 Interrupts 1

INTERRUPTS An interrupt is a signal to the CPU from hardware external to the CPU that indicates than some event has occured, e.g. data has arrived at an input interface. CPUs respond to an interrupt by switching from executing the instructions of the current program to executing instructions to handle the event that caused the interrupt. The interrupt mechanism provides an efficient way to detect the occurrence of an event. It is important to understand the implementation of interrupts and when they should or should not be used. Interrupts are a key element in the operation of most computer systems. 20/11/2006 1001 Interrupts 2

Why interrupts? Polling is inefficient when data rates are low: - too many CPU cycles wasted executing instructions of polling loop. Polling is the wrong approach to handling events where the time of the occurrence of an event is uncertain or distant, i.e. 100s of clock cycles away. Start Read Status Register Start Read Status Register The occurrence of the event should be the trigger for CPU action, the CPU should not be checking for the event. Examples of similar systems: a knock on the door, the ringing of the telephone Buffer Full? Y Read Data from Data Port Buffer Empty? Y Write Data intodata Port 20/11/2006 1001 Interrupts 3 End N End Example polling software on input and output interfaces N

Points to cover:- how is interrupt signal generated how are interrupts prioritised, if there are several at same time how does CPU identify event that generated interrupt how does CPU switch from to running software to deal with event how is it that program running at time of interrupt is not affected how does interrupt software exchange data with rest of system how are interrupts prioritised, if there are several at same time 20/11/2006 1001 Interrupts 4

8-Bit Parallel Output Interface READ 8-Bit Parallel Input Interface READ Data Bus WRITE interrupt Data Reg Status Reg Output Data Input Data Flow Control Signals Data Reg Status Reg Data Bus interrupt Address Bus Select Signals Select Signals Address Bus When Rx acknowledges receipt of data the TX interrupt request is activated Writing new data into the Data Register or reading Status Register deactivates TX interrupt request Arrival of new data triggers activation of interrupt request Reading data from Data Register deactivates interrupt request 20/11/2006 1001 Interrupts 5

I/O INT Interface INTERRUPT HARDWARE To I/O devices I/O INT Interface I/O INT Interface I 1 I 2 I 3 I n Interrupt Controller Interrupt Request Interrupt CPU I/O INT Interface Data Bus Decoder Address Bus Data Bus 1) I/O interface generates an interrupt request signal, on some Tx or Rx event. 2) Interrupt Controller generates an interrupt request to CPU, when one or more inputs is active. 3) CPU reads Interrupt Controller to get number (vector) identifying the highest priority active interrupt request (priority in by input number, or rotating priority allocation: the vector identifies the highest priority interrupt device requiring service. [This is why the controller is shown with connections to the system busses:to read vector] 20/11/2006 1001 Interrupts 6

CPU Activity in servicing an Interrupt Request When Interrupt Request becomes active, CPU completes current instruction, and then executes the following operations automatically:- CPU saves PC register & turns off interrupts CPU loads PC with new value CPU resumes instruction processing CPU switches to execute software in response to the interrupt. Software handles event that occurred, e.g. data received. This software is called the Interrupt Service Routine (ISR). At end of ISR, CPU continues the interrupted program. Alternatives: Once in the ISR, software can determine whether to return to the interrupted program, to suspend it or to close it down. ISR now executes to deal with event generating interrupt until... CPU resumes instruction processing of interrupted program at end of ISR CPU loads registers and PC with values saved at start of interrupt service, a special return-frominterrupt instruction is executed to re-enable interrupts 20/11/2006 1001 Interrupts 7

Another way of viewing of Interrupt Servicing Instructions of program being executed by CPU Interrupt Service Routine (ISR) general structure Interrupt Request PC saved, PC loaded with new value further interrupts disabled PC reloaded Interrupts re-enabled Save CPU registers changed in ISR Handle event that caused interrupt, e.g. input data, output data acknowledged. Restore CPU registers saved at start of ISR Return-from-interrupt Instruction executed Interrupt is very like a hardware generated function call: Saving/restoring registers ensures state of interrupted program is not changed by interrupt servicing. stack is used to save state 20/11/2006 1001 Interrupts 8

Where does new PC address come from? Non-vectored interrupts: new PC address is defined in CPU hardware, always go to same address: find source of event by polling IO interfaces slow! Vectored Interrupts: Vector read from controller is used to look up the address of software to handle interrupt, and placed in PC. This activity is done by the hardware. This allows CPU to get quickly to the software to handle the event. The interrupt table has to be set up by software, whichever mechanism is used. vector PC Interrupt table in memory MIPS uses Non-vectored interrupt, so ISR is found by software. 20/11/2006 1001 Interrupts 9

Interrupt are very good for low frequency data. There is a large overhead in saving and restoring program state (registers & PC), which limits the maximum frequency of data that can be handled. 20/11/2006 1001 Interrupts 10

How does ISR handle interrupt event? One way is to use circular buffers to queue data Input Device: data removed by consumer from head of queue at convenient time ISR puts input data on to tail of queue in circular buffer. Output Device: Data producer puts output data into tail of queue. data removed from head of queue by ISR and output 20/11/2006 1001 Interrupts 11

Timer Device CPU loads count into count-down register. Register counted down by clock. At zero, interrupt generated and register reloaded. Clock Timer Device Count-down Register Interrupt Request Count-down register loaded over data bus by software: timer looks like I/O device to CPU. Decoder Data Bus Address Bus Timer generates interrupts at regular time intervals. Instead of re-starting interrupted program after timer interrupt, operating system may suspend this program and switch to run another program. Thus, each program is executed for a time slice at regular intervals: this is how an operating system runs several programs at once. 20/11/2006 1001 Interrupts 12

Exceptions These are very similar to interrupts in many ways. Exceptions are caused by the current instruction being executed. Interrupts are always triggered outside the CPU and are caused by events that are being awaited e.g. an I/O transfer completing, a timer count elapsing. Exceptions are either triggered inside the CPU or is caused by an error condition on a transfer to memory or I/O interface. The last is signalled via BUS ERROR input to the CPU. Internal CPU exceptions are often error conditions, e.g. divide-by-zero exception. An exception is processed in an exactly similar way to an Interrupt except that the vector used to look up the vector table is generated by the CPU. Exceptions are generally triggered by software actions rather than hardware events. 20/11/2006 1001 Interrupts 13

MIPS Operation On interrupt/exception: Hardware operations wait for completion of current instruction save pc to epc register (exception program counter register) set type of event in cause register load pc with address 80000080 restart execution Interrupt/Exception Service Routine resides at address 0x80000080 The ISR must discover the cause of the event and then execute software to deal with the event. It is the ISR responsibility to save the state (register values) of the interrupted program if this program is to be continued later. If interrupt occurred, then must discover what device generated it. 20/11/2006 1001 Interrupts 14

MIPS Interrupt hardware epc register set with pc value on interrupt so that pc can be changed mfc0 instruction reads epc register into another register interrupt status register has interrupt masks to enable/disable different interrupts & exceptions - special instructions to access cause register holds information on interrupt/exception source - special instructions to access sources: interrupt address error exception on load address error exception on load bus error on instruction fetch bus error on data load or store system call exception breakpoint exception reserved instruction exception arithmetic overflow exception 20/11/2006 1001 Interrupts 15