Introduction to Interrupts

Slides:



Advertisements
Similar presentations
1 Exceptions, Interrupts & Traps Operating System Hebrew University Spring 2007.
Advertisements

Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Chapter 12: Interrupts. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. The Intel Microprocessors:
I/O Unit.
Unit 4 Chapter-1 Multitasking. The Task State Segment.
Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks.
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.
LOGO Chapter 1 Interrupt handling. hardware interrupt Under x86, hardware interrupts are called IRQ's. When the CPU receives an interrupt, it stops whatever.
Interrupt Processing Haibo Wang ECE Department
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.
Linux Operating System
Introduction to Computer Engineering by Richard E. Haskell Interrupts Module M17.3 Sections 11.3, 14.1.
Exceptions, Interrupts & Traps
Chapter 11 Interrupt Interface of the 8088 and 8086 Microcomputer
Interrupts – (Chapter 12)
Lecture 09: Interrupts & 8259.
Interrupts Chapter 20 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
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.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
MICROPROCESSOR INPUT/OUTPUT
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
1 COMPUTER ARCHITECTURE (for Erasmus students) Assoc.Prof. Stasys Maciulevičius Computer Dept.
Lecture 09: Interrupts & The 80x86 IBM PC and Compatible Computers Chapter 14 Interrupts and the 8259 Chip.
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;
CSC 2405 Computer Systems II Exceptions Mini-Lecture Traps & Interrupts.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
INT- interrupt program execution 1. It decrements the sp by 2 and pushes the flag registers on the stack. 2. Decrement the sp by 2 and push the content.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
8086 Microprocessor Interrupts By: Vijay Kumar. K Reference From Slide Share.
Exceptional Control Flow Topics Exceptions except1.ppt CS 105 “Tour of the Black Holes of Computing”
Dec Hex Bin 14 E ORG ; FOURTEEN Interrupts In x86 PC.
University of Washington Exceptional Control Flow The Hardware/Software Interface CSE351 Winter 2013.
8086 Interrupts and Interrupt Applications
EEL 3801 Part IV The Assembler. OFFSET Operator Returns address of variable used as operand. Actually, it represents the offset from the beginning of.
University of Tehran 1 Microprocessor System Design Programmable Interrupt Controller Omid Fatemi
Assembly 08 Interrupts. Introduction Interrupts are similar to procedures –They are used to alter a program’s control flow –The interrupt service is also.
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 11.
Microprocessor System Design Programmable Interrupt Controller.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Interrupt-Driven I/O There are different types of interrupts –Hardware Generated by the 8259 PIC – signals the CPU to suspend execution of the current.
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
1 Interrupts A Course in Microprocessor Electrical Engineering Dept. University of Indonesia.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Interrupt Processing Sequence
Interrupts and exceptions
Interrupts and interrupt responses
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
Exceptional Control Flow
Microprocessor Systems Design I
The process starts from the I/O device
Anton Burtsev February, 2017
Interrupts In 8085 and 8086.
Interrupts – (Chapter 12)
Computer Organization And Assembly Language
Basic Microprocessor Architecture
Microprocessor and Assembly Language
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
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.
11.1 Interrupt Mechanism, Type, and Priority
Exceptions Control Flow
Interrupts.
CNET 315 Microprocessor & Assembly Language
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Presentation transcript:

Introduction to Interrupts COE 205 Computer Organization and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals

Outline Introduction Interrupts vs. Procedures A Taxonomy of Interrupts Software Interrupts Hardware Interrupts Processor Interrupts or Exceptions Interrupt Processing Dedicated Interrupts

Introduction Interrupt is a mechanism by which a program's flow of control can be altered. When an interrupt occurs, the CPU suspends its execution of the current program, and transfers control to an Interrupt Service Routine (ISR), also called a Handler, that will provide the requested service by the interrupt. When the ISR is completed, the original program resumes execution as if it were not interrupted.

Interrupts vs. Procedures Although the behavior of interrupts is analogous to procedures, there are some basic differences that make interrupts almost indispensable. These differences are highlighted below: Interrupts can be initiated by both software and hardware. However, procedures can be initiated only by software. Interrupt mechanism provides an efficient way to handle unanticipated events. For example, if the program goes into an infinite loop, ctrl-break could cause an interrupt to suspend the program execution. Interrupt Service Routines are memory resident while procedures are loaded with application programs. Interrupts are identified by numbers while procedures are identified by names.

A Taxonomy of Interrupts There are three main types of interrupts: Software interrupts Hardware interrupts Processor interrupts or Exceptions

Software Interrupts Initiated by executing the interrupt instruction INT in a program. Mainly used in accessing I/O devices such as the keyboard, printer, screen, disk drive, etc. For example, we use the INT 21H instruction to read a character or a string from the keyboard or display a character or a string on the screen. Software interrupts can be classified into system-defined or user-defined. System-defined software interrupts are those whose interrupt service routines are supported by BIOS and DOS.

Software Interrupts User-defined interrupts are those whose interrupt service routines are provided by the user. The format of the interrupt instruction is: INT interrupt-type interrupt-type is an integer in the range 0 through 255. Thus, there are 256 different interrupt types. This is a sufficiently large number, as each interrupt type can be parameterized to provide several services. For example, there are more than 80 different services (called functions) provided by DOS through INT 21H.

Hardware Interrupts Hardware interrupts are generated by hardware devices to get the attention of the CPU. For example, when a key is pressed, the keyboard generates an interrupt causing the CPU to suspend its present activity and execute the keyboard interrupt service routine to process the key. Hardware interrupts can be either maskable or non-maskable. Maskable interrupts are initiated through the CPU pin INTR while non-maskable interrupts are initiated through the CPU pin NMI.

Hardware Interrupts Non-maskable interrupts are serviced by the CPU immediately after completing the execution of the current instruction. e.g. RAM parity error indicating memory malfunction Maskable interrupts can be delayed until execution reaches a convenient point. The Interrupt Flag (IF) controls whether maskable interrupts are delayed or not. When IF=1, maskable interrupts will be serviced by the CPU, otherwise they will be delayed until the IF becomes 1. The instruction STI can be used to set the interrupt flag The instruction CLI can be used to clear the interrupt flag.

Hardware Interrupts Identifying Hardware Interrupt Types In response to a hardware interrupt request on the INTR pin, the CPU initiates an interrupt acknowledge sequence. The CPU sends out an interrupt acknowledge (INTA) signal, The interrupting device places the interrupt type number on the data bus. Handling Interrupts from Several I/O Devices All interrupts requested from external devices are maskable and initiated through the INTR pin. When more than one device interrupts, interrupts are prioritized and only one interrupt request is forwarded to the CPU while other interrupt requests remain pending using a special chip -- the Intel 8259 Programmable Interrupt Controller.

Processor Interrupts or Exceptions Exceptions are processor interrupts to handle instruction faults. An example of an exception is the divide error fault, which is generated when the quotient can not fit in the quotient register. Exceptions are classified into three types depending on the way they are reported and whether or not the instruction that interrupted is restarted: Faults Traps Aborts

Processor Interrupts or Exceptions Faults and traps are reported at instructions boundaries. When a fault is reported, the system state is restored to the state before the instruction that caused the interrupt so that the instruction can be restarted. Examples of faults are the divide error fault and the segment-not-present fault. The segment-not-present fault is caused by a reference to data in a segment that is not in memory. Then, the exception handler must load the missing segment from the hard disk and resume program execution starting with the instruction that caused the exception.

Processor Interrupts or Exceptions When a trap is reported, the system state is restored to the state after the instruction that caused the interrupt. An example of a trap is the overflow exception (INT 4). Aborts are exceptions that report severe errors. Examples include hardware errors and inconsistent values in system tables.

Interrupt Processing When the CPU is started, the BIOS and DOS ISRs are loaded into memory and they stay memory resident. In order to have flexibility in storing these ISRs in memory in any location, their addresses are stored in an interrupt descriptor table (IDT) or interrupt vector table (IVT). Interrupt number is used as an index into the Interrupt Descriptor Table (IDT)

Interrupt Processing In protected mode, the IDT can be stored at any location and its address is stored at the 48-bit register IDTR. The address of an ISR requires 8 bytes. So, the size of the IDT is 2048 bytes. Interrupt number is multiplied by 8 to get byte offset into IDT In real mode, the IDT is stored at base address 0. The address of an ISR requires 4 bytes only, 2 bytes for the IP offset and 2 bytes for the CS. Interrupt number is multiplied by 4 to get byte offset into IDT

Real Mode IDT For example, the ISR pointer for INT 0 is 0000h, the pointer for INT 1 is 0004h, the pointer for INT 2 is 0008h, and the pointer for INT 21h is 0084h. For INT 21h, the IP register will be loaded with the 16-bit from addresses [0085:0084] and the CS register will be loaded with the 16-bit from addresses [0087:0086].

Interrupt Processing When an interrupt occurs, the following action is taken by the CPU for protected mode: Push EFLAGS register onto the stack, Clear interrupt and trap flags to disable further interrupts sti can be used to set interrupt flag cli can be used to clear interrupt flag Push CS register onto the stack, Push EIP register onto the stack, Load CS register with the 16-bit at memory address from IDT Load EIP register with the 32-bit from IDT

Interrupt Processing Just like procedures, ISRs should end with a return statement to send control back to the interrupted program. The interrupt return instruction, IRET, is used for this purpose. When the IRET instruction is executed in protected mode, the CPU performs the following steps: Pop the 32-bit from the top of the stack into the EIP register, Pop the 16-bit from the top of the stack into the CS register, Pop the 32-bit from the top of the stack into the EFLAGS register.

Dedicated Interrupts Several Pentium predefined interrupts --- called dedicated interrupts These include the first five interrupts: interrupt type Purpose 0 Divide error 1 Single-step 2 Nonmaskable interrupt (NMI) 3 Breakpoint 4 Overflow

Dedicated Interrupts Divide Error Interrupt Single-Step Interrupt CPU generates a type 0 interrupt whenever the div/idiv instructions result in a quotient that is larger than the destination specified Single-Step Interrupt Useful in debugging To single step, Trap Flag (TF) should be set CPU automatically generates a type 1 interrupt after executing each instruction if TF is set Type 1 ISR can be used to present the system state to the user

Dedicated Interrupts Breakpoint Interrupt Overflow Interrupt Useful in debugging CPU generates a type 3 interrupt Generated by executing a special single-byte version of int 3 instruction (opcode CCH) Overflow Interrupt Two ways of generating this type 4 interrupt int 4 (unconditionally generates a type 4 interrupt) into (interrupt is generated only if the overflow flag is set) We do not normally use into as we can use jo/jno conditional jumps to take care of overflow