Interrupt: (verb) the interruption of a CPU s normal processing...using a mechanism provided for this purpose.

Similar documents
Lecture 4: Mechanism of process execution. Mythili Vutukuru IIT Bombay

Definition: An operating system is the software that manages resources

13-2 EE 4770 Lecture Transparency. Formatted 8:18, 13 March 1998 from lsli

ECE 650 Systems Programming & Engineering. Spring 2018

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Reset, Interrupts, Exceptions, and Break ECE 3534

An overview of Interrupts ECE3534

Input / Output. School of Computer Science G51CSA

Microprocessors & Interfacing

Interrupts (I) Lecturer: Sri Notes by Annie Guo. Week8 1

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

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

INTERRUPTS in microprocessor systems

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

EE458 - Embedded Systems Exceptions and Interrupts

Source EE 4770 Lecture Transparency. Formatted 16:43, 30 April 1998 from lsli

Interrupts and real time

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Input/Output Systems

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

CSE 153 Design of Operating Systems

Hardware OS & OS- Application interface

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

CHAPTER 11 INTERRUPTS PROGRAMMING

Resource Management IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

Notes Interrupts and Exceptions. The book uses exception as a general term for all interrupts...

COSC 243. Input / Output. Lecture 13 Input/Output. COSC 243 (Computer Architecture)

COMP I/O, interrupts, exceptions April 3, 2016

INPUT/OUTPUT ORGANIZATION

lecture 21 Input / Output (I/O) 3 - system bus and memory (lectures revisited) - system bus and interrupts - exceptions (lecture 12 revisited)

ECE 341. Lecture # 19

Input Output (IO) Management

CS 134. Operating Systems. April 8, 2013 Lecture 20. Input/Output. Instructor: Neil Rhodes. Monday, April 7, 14

Lecture 2: Architectural Support for OSes

Embedded System Design

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

Chapter 13: I/O Systems

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

18-349: Introduction to Embedded Real-Time Systems

Architectural Support for Operating Systems

Chapter 3 - Top Level View of Computer Function

Computer System Overview

CPS221 Lecture: Operating System Protection

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

OS Structure. Hardware protection & privilege levels Control transfer to and from the operating system

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

3.1 Introduction. Computers perform operations concurrently

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

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

C02: Interrupts and I/O

Module 12: I/O Systems

Today: Computer System Overview (Stallings, chapter ) Next: Operating System Overview (Stallings, chapter ,

Lecture 10 Exceptions and Interrupts. How are exceptions generated?

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

8086 Interrupts and Interrupt Responses:

HANDLING MULTIPLE DEVICES

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

Operating system issues

CSE 153 Design of Operating Systems Fall 18

SMD149 - Operating Systems

CS370 Operating Systems

Introduction to Operating Systems. Chapter Chapter

Operating Systems 2010/2011

Task Based Programming Revisited Real Time Operating Systems

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

Why use an Operating System? Operating System Definition

PC Interrupt Structure and 8259 DMA Controllers

CSE 120 Principles of Operating Systems

Inf2C - Computer Systems Lecture 16 Exceptions and Processor Management

An Operating System in Action

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Q.1 Explain Computer s Basic Elements

INPUT/OUTPUT ORGANIZATION

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6

CPS221 Lecture: Operating System Functions

Chapter 13: I/O Systems

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

W4118: interrupt and system call. Junfeng Yang

Control unit. Input/output devices provide a means for us to make use of a computer system. Computer System. Computer.

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University

Lecture 13 Input/Output (I/O) Systems (chapter 13)

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

CSE 120 Principles of Operating Systems

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

KERNEL THREAD IMPLEMENTATION DETAILS. CS124 Operating Systems Winter , Lecture 9

Lecture 23. I/O, Interrupts, exceptions

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

Chapter 3. Top Level View of Computer Function and Interconnection. Yonsei University

Anne Bracy CS 3410 Computer Science Cornell University

Introduction to Computers and Programming

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

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

Bringing Organization to our Code (the shared-data problem)

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Interrupt/Timer/DMA 1

Transcription:

15-1 Interrupts 15-1 Interrupt: (verb) the interruption of a CPU s normal processing......using a mechanism provided for this purpose. Interrupt: (noun)......(1)aneventthatcausesaninterrupt......(2) the interface and CPU hardware implementing a particular interrupt level. An interrupt can be any of the following: Interruption by an external device. In class, this is what is meant by interrupt. Interruption by attempted illegal instruction or memory access. Also called exceptions. Interruption by timer within computer. Interruption by execution of a special instruction. Also called traps. (Used for system calls.) In this set, external device interrupt will be covered. 15-1 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-1

15-2 15-2 External Device Interrupts Hardware & Software Involved External Event Possible events Temperature exceeding limit. Person pressing a button. Disk drive signaling that data is ready. Sensor, Conditioning Circuit, Etc. Converts event to a logic level. This was covered earlier in the semester. Computer Input, Called Interrupt Request (IRQ) Usually several IRQs available. A single IRQ can be shared. Kernel Code Called Service Routine Attends to routine matters. Kernel Code Called Handler Called by service routine. Attends to cause of interrupt. 15-2 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-2

15-3 15-3 Interrupt Steps, Overview Overview of Interrupt Activities Event occurs. Detected by sensor. An IRQ asserted by conditioning-circuit output. When CPU allows interruption...... it finishes in-progress instructions...... prevents (masks) other interrupts...... and jumps to service routine. Service routine...... saves context...... determines source of interrupt...... and calls handler for interrupt source. Handler...... stops interrupt...... and carries out interrupt-specific activities. After the handler returns...... the service routine restores registers...... and any interrupted task resumed. 15-3 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-3

15-4 15-4 Software Interrupts Exceptions These are caused by illegal instructions, operands, and memory accesses. The service routine can usually determine the reason for the exception by examining a register. The OS may stop the task or run a task-provided handler. These will not be discussed further. Traps These are special instructions which work something like interrupts. They are used for system calls, the type of system call is placed in a register before executing the trap. After the trap is executed, the register s contents will be examined by the service routine. These will not be discussed further. 15-4 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-4

15-5 15-5 Interrupt Masking Please Do Not Disturb Untimely interruptions cause errors, etc. Therefore, interrupt requests sometimes temporarily ignored. Ignored by masking the interrupts. Mask Register Interrupts masked using a mask register. Mask register typically has one bit per IRQ line. When bit is set, corresponding interrupt ignored. (Ignored interrupts usually persist until unmasked.) Frequently, all interrupts masked. 15-5 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-5

15-6 15-6 Reasons For Ignoring Interrupts Already Handling Event Manipulating Shared Data Cannot stop in middle......without confusing next reader of shared data. This is important, but not covered here. Responding to Higher-Priority Event Done for performance reasons. The Non-Maskable Interrupt (NMI) Interrupt that cannot be masked. Used for events that, if ignored, will damage system. NMI Usage Use of an NMI could also damage system,...... but hopefully less than ignoring NMI. NMIs also used to get control of hung system. DOS/Windows 3.X and Macintosh users make frequent use of NMIs. 15-6 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-6

15-7 15-7 (Strong) Interrupt Priority IRQ Choice Several IRQs can be simultaneously asserted. Hardware chooses using strong priority......a priority policy implemented by CPU interrupt hardware. Priorities Levels Usually based on labels of IRQ inputs. E.g., IRQ3 before IRQ2. About 10 levels typically available. 15-7 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-7

15-8 15-8 Interrupt Vector Table The interrupt vector table (IVT) is......used by the hardware......to find an interrupt s service routine. IVT Structure Table of memory addresses......kept in special place in memory. One entry for each IRQ. Table entry points to IRQ s service routine. IVT Use Suppose IRQi is asserted while unmasked:...cpu will finish current instruction......will read address in entry i of IVT......and jump to this address while switching to privileged mode. 15-8 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-8

15-9 15-9 Service Routine Service Routine First code executed after interrupt. Prepares system for handler. Service Routine Actions Context information saved. Some interrupts may be unmasked. IRQ that caused interrupt is not unmasked. (If it were the handler might never start.) Find source of interrupt. (Poll interrupts.) Start Handler After handler finishes, Returns mask to its previous value. Return to interrupted task. Finding Interrupt Source Called: interrupt polling. Reason: an IRQ can be shared by interrupt sources. Side Effect: A second round of priority, weak priority. 15-9 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-9

15-10 15-10 Interrupt Polling Polling: checking external devices to determine interrupt source. Procedure Start with list of possible sources. Use I/O port to check each source. Note which sources are requesting interrupt. First Come, Maybe First Served Interrupts can happen any time. Suppose interrupt X is asserted on IRQ1. Moments later interrupt Y, also on IRQ1, is asserted. Suppose the service routine checks Y before X. Then Y not X serviced first. (X serviced after Y ). 15-10 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-10

15-11 15-11 Polling Sequence and Weak Priority Order of checking is called polling sequence. Possible orders: round robin (with each interrupt source a class) or priority. Priority implemented by polling sequence called weak priority. Interrupt Source Choice Polling creates something like a ready list. Many different scheduling policies could be used, but...... since interrupt latency should be small...... only fast methods are used. E.g., start handler for first active source found. 15-11 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-11

15-12 15-12 The Interrupt Hander Interrupt handler: code written to attend to interrupt. Interrupt handler must stop the interrupt......and attend to event that caused the interrupt. An interrupt handler should finish quickly......because while it s running other interrupts may be blocked. Blocked interrupts may miss deadlines......or result in unacceptable performance. Options for interrupts requiring lengthy service. Handler would attend to any time-critical parts...... while remainder handled by either...... a second-level handler...... or a dæmon (or other type of) task. Second-Level Handler Definition: Code implementing second part of handler. Can run with fewer interrupts masked. Advantage: does not block higher-priority interrupts. Two-Level Interrupts Definition: interrupt using a second-level handler. 15-12 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-12

15-13 15-13 End of Interruption Suppose the handler has finished, and no other same-level interrupts are pending. Then the interrupt mask is restored to its previous value. In task-preemptive systems, the scheduler might be called before the task returns. Otherwise, the interrupted task will resume. 15-13 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-13

15-14 15-14 Keyboard Example How a pressed key on a keyboard results in a character stored in a user task s memory. This does not describe any particular system. 1 The Hardware Keyboard consists of a grid of switches. Pressing a key closes a switch. Keyboard hardware generates two outputs: An interrupt request. This is asserted when any key changes state. Suppose this is connected to IRQ3. A scan code. This is read through an I/O port. The Software The IRQ3 service routine. The handler. This reads the scan code. The server (on X-Window systems). This converts the code into an event, and sends a message, including the event, to the appropriate task. The task. The code for which the key is intended. 1 I made up some details. 15-14 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-14

15-15 15-15 Sequence of Events 1: A key is pressed. 2: IRQ3 line is asserted. 3: Interrupt starts if/when level 3 unmasked. 4: At start of interrupt all interrupts are masked. 5: Jump to address stored at entry 3 in IVT, starting the service routine. 6: Context saved and some interrupts are unmasked. 7: Poll devices connected to IRQ 3. 8: Poll results: keyboard requested an interrupt, so keyboard handler started. 9: Handler reads scan code from I/O port. 10: Handler takes whatever action is necessary to stop the interrupt. 11: Scan code translated into device-independent form, called a key code. 12: Key code written into an area of memory accessible to server. 13: Finally, the handler signals the server that a new key is available. 14: Handler returns to the service routine. 15: Service routine returns the mask to its state before the interrupt. 16: Service routine returns to the running task. 15-15 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-15

15-16 15-16 Later. 17: Server task moves to Run state. 18: Server task reads key code and dispatches a message to relevant task. Later. 19: Relevant task moves to Run state. 20: Finds message containing key value. The server s work in processing keyboard input could have been done by the handler. However, that might result in poor performance because of the handler taking too long to run. 15-16 EE 4770 Lecture Transparency. Formatted 8:15, 22 March 1999 from lsli15. 15-16