Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO 63130.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Tutorial 3 - Linux Interrupt Handling -
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Chapter 6 Limited Direct Execution
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Exception and Interrupt Handling
Introduction to Embedded Systems
Protection and the Kernel: Mode, Space, and Context.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure.
NT Kernel CS Spring Overview Interrupts and Exceptions: Trap Handler Interrupt Request Levels and IRT DPC’s, and APC’s System Service Dispatching.
Fall 2013 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.
Review The Joys and Pains of Threads and Multithreading –what is a thread –threads vs. processes –opportunities and risks.
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.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Preemptive Context Switching
University of Washington Exceptional Control Flow The Hardware/Software Interface CSE351 Winter 2013.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
How & When The Kernel Runs David Ferry, Chris Gill Department of Computer Science and Engineering Washington University, St. Louis MO
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.
Linux Boot Process on the Raspberry Pi 2 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis,
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Interrupts and Exceptions 國立中正大學 資訊工程研究所 羅習五 老師. Interrupt & Exceptions Interrupts – maskable & nonmaskable interrupt Exceptions – Processor-detected.
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Introduction to Operating Systems Concepts
Computer System Structures Interrupts
CS 3214 Computer Systems Lecture 9 Godmar Back.
Linux Kernel Development - Robert Love
Processes and threads.
Linux Details: Device Drivers
Interfacing with Hardware
How & When The Kernel Runs
Midterm Review Chris Gill CSE 422S - Operating Systems Organization
Exceptional Control Flow
Anton Burtsev February, 2017
Midterm Review David Ferry, Chris Gill
Exceptional Control Flow
Exceptional Control Flow
Semester Review Chris Gill CSE 422S - Operating Systems Organization
Interrupts and Interrupt Handling
Architectural Support for OS
Linux Details: Device Drivers
Top Half / Bottom Half Processing
Kernel Synchronization I
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
How & When The Kernel Runs
Chapter 4: Threads.
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Interrupts and Interrupt Handling
Processes David Ferry, Chris Gill, Brian Kocoloski
Interrupts and System Calls
Presentation transcript:

Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO

Why Interrupts? Interrupts allow a currently executing process to be preempted Without interrupts, a process could only be removed from the processor when it ended or voluntarily yielded Interrupt use cases: – The timer interrupt controls the scheduling frequency of a system – Peripheral devices use interrupts to request CPU attention – Processors use interrupts to communicate in multi- processor systems (e.g. for load balancing or synchronization) CSE 522S – Advanced Operating Systems2

Interrupt Mechanisms On the ARM architecture, there are three physical types of interrupts: – SWI: software interrupts (i.e. exceptions) – IRQ: regular hardware interrupts – FIQ: fast hardware interrupts Linux has three interrupt semantics: – Software interrupts routed via SWI table – Hardware interrupts routed via the IDT – Inter-processor interrupts CSE 522S – Advanced Operating Systems3

Software vs Hardware Interrupts Software interrupts we saw before: – User mode initiates system calls with the SWI instruction (or on x86, the INT instruction) – Illegal instructions are trapped – Occurs synchronously with processor instructions Hardware interrupts are from devices: – Indicated by an electrical signal to a processor – On ARM, multiplexed by the Generic Interrupt Controller (GIC) – Asynchronous with instruction stream CSE 522S – Advanced Operating Systems4

Hardware Interrupt Interface Register new handlers with request_irq(), three key attributes: – IRQ number – IRQ handler function – Whether the IRQ is shared Handler functions execute in interrupt context: – Disables own interrupt line (optionally all interrupts) – May be interrupted by other interrupts – Does not need to be re-entrant – Cannot sleep CSE 522S – Advanced Operating Systems5

Hardware Interrupt Tension Handlers must be fast no matter what task requires: – Can preempt more important work – Disables own interrupt line (bad for shared lines), and may disable all lines – Must perform potentially large amounts of work to service hardware – Cannot sleep/block, so cannot call functions that can sleep/block (such as kmalloc() ) Strategy: Service hardware immediately but defer as much work as possible till later. CSE 522S – Advanced Operating Systems6

Top Half / Bottom Half Modern interrupt handlers are split into top half (fast) and bottom half (slow) components Top half: – Does minimum work to service hardware – Sets up future execution of bottom half – Clears interrupt line Bottom half: – Performs deferred processing Example: Network card – top half clears card buffer while bottom half processes and routes packets CSE 522S – Advanced Operating Systems7

Bottom Half Mechanisms Softirqs (interrupt context) – Statically defined – Most concurrency / performance – Same softirq handler can execute concurrently on different processors Tasklets (interrupt context) – Should be your default choice over softirqs – Tasklet handlers of same type do not execute concurrently Work Queues (process context) – Defers work to generic kernel threads ( kworker ) – Can sleep – Replaces making your own deferred kernel thread CSE 522S – Advanced Operating Systems8

Hardware Interrupt Implementation Sequence of events: – Someone registers a handler on specific IRQ line – Device raises interrupt line with GIC – GIC de-multiplexes and interrupts CPU – CPU jumps to interrupt descriptor table (IRQ table or FIQ table) in entry_armv.S via svn_entry and irq_handle – C code starts at asm_do_irq() – generic_handle_irq() (arch independent in kernel/irq/irqdesc.c) – Proceeds to specific handlers from there – Return after executing all handlers CSE 522S – Advanced Operating Systems9

Inter-processor Interrupts (IPIs) Modern multi-core machines need a way for cores to communicate. – Start/stop/sleep/wakeup other cores – Request task migration – Request remote function call (synchronization) Implemented differently from traditional interrupts, see smp_cross_call() in arch/arm/kernel/smp.c CSE 522S – Advanced Operating Systems10