Interrupts and Interrupt Handling

Slides:



Advertisements
Similar presentations
Tutorial 3 - Linux Interrupt Handling -
Advertisements

Chapter 6 Limited Direct Execution
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Protection and the Kernel: Mode, Space, and Context.
CSC 2405 Computer Systems II Exceptions Mini-Lecture Traps & Interrupts.
Exceptional Control Flow Topics Exceptions except1.ppt CS 105 “Tour of the Black Holes of Computing”
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
University of Washington Exceptional Control Flow The Hardware/Software Interface CSE351 Winter 2013.
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.
Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
Introduction to Operating Systems Concepts
Input / Output Chapter 9.
Computer System Structures Interrupts
Chapter 13: I/O Systems.
Introduction to Kernel
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Chapter 2: Computer-System Structures(Hardware)
Linux Kernel Development - Robert Love
Chapter 2: Computer-System Structures
Processes and threads.
Linux Details: Device Drivers
Interrupts and signals
Operating Systems CMPSC 473
Exceptional Control Flow
Interfacing with Hardware
Basic Processor Structure/design
CS 6560: Operating Systems Design
How & When The Kernel Runs
Exceptional Control Flow
Anton Burtsev February, 2017
Midterm Review David Ferry, Chris Gill
Exceptional Control Flow
Exceptional Control Flow
CS 286 Computer Organization and Architecture
Chapter 3 Top Level View of Computer Function and Interconnection
CS703 - Advanced Operating Systems
Interrupts and Interrupt Handling
ECEG-3202 Computer Architecture and Organization
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
COMPUTER PERIPHERALS AND INTERFACES
Exceptions Control Flow
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.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
How & When The Kernel Runs
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
Linux Block I/O Layer Chris Gill, Brian Kocoloski
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
William Stallings Computer Organization and Architecture 7th Edition
Processes David Ferry, Chris Gill, Brian Kocoloski
Page Cache and Page Writeback
Interrupts and System Calls
Module 12: I/O Systems I/O hardwared Application I/O Interface
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Interrupts and Interrupt Handling David Ferry, Chris Gill, Brian Kocoloski CSE 422S - Operating Systems Organization Washington University in St. Louis St. Louis, MO 63130

System Architecture CPU DRAM System Bus GIC Peripheral Devices (hard drives, keyboards, adapters, etc. Bridge I/O buses GIC: Generic Interrupt Controller CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization System Architecture CPU DRAM System Bus GIC Bridge PCI bus CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization System Architecture CPU DRAM System Bus New packets come in GIC Bridge PCI bus CSE 422S – Operating Systems Organization

System Architecture CPU DRAM System Bus GIC Bridge PCI bus Hey kernel --- I need you to process these new packets CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization System Architecture CPU DRAM System Bus GIC interrupt Bridge PCI bus CSE 422S – Operating Systems Organization

System Architecture CPU DRAM System Bus GIC Bridge IO bus Write to a file on a hard drive CSE 422S – Operating Systems Organization

System Architecture CPU DRAM System Bus GIC Bridge IO bus Read from a file on a hard drive CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization Why Interrupts? Interrupts force the currently executing process to be preempted Without interrupts, a process could only be removed from the processor when it ended or voluntarily yielded Interrupts allow timely processing of hardware events Interrupts preclude the need for a (fast) CPU to poll on status of (slow) peripheral hardware Three primary interrupt use cases: Peripheral devices use interrupts to request CPU attention The timer interrupt controls the scheduling frequency of a system Processors use interrupts to communicate in multi-processor systems (e.g. for load balancing or synchronization) CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization https://www.slideshare.net/AnhDungNGUYEN3/arm-aae-system-issues CSE 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization 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 Interrupt Descriptor Table (IDT) Inter-processor interrupts CSE 422S – Operating Systems Organization

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 Also called “exceptions” or “traps” 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 422S – Operating Systems Organization

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 422S – Operating Systems Organization

CSE 422S – Operating Systems Organization System Architecture Inter-processor interrupt Used to send interrupts between CPUs; eg., for: Task migration Flushing of low-level caches CPU DRAM System Bus CPU GIC CSE 422S – Operating Systems Organization

Hardware Interrupt Interface Register new handlers with request_irq(), using three key attributes: IRQ number IRQ handler function Whether the IRQ is shared Handler functions execute in interrupt context: No process context No current, no mm_struct, etc. Disables own interrupt line (optionally all interrupts) May be interrupted by other interrupts Does not need to be re-entrant Cannot sleep CSE 422S – Operating Systems Organization

Differences Between Process and Interrupt Context Process Context Kernel is executing on behalf of a process current points to the currently executing process Can sleep (as long as it doesn’t hold a lock) Locks can be taken without disabling interrupts Interrupt Context Kernel is executing with no associated process context No user-level process No kernel thread There is no thread context on the CPU; current points to the last interrupted process Cannot sleep – how would the kernel re-schedule it without a process context? All interrupts must be disabled (on this core) before locks can be taken CSE 422S – Operating Systems Organization

Hardware Interrupt Tension Handlers must be fast Disables own interrupt line (bad for shared lines), and may disable all lines Can preempt more important work But also may have to do a lot of work 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 422S – Operating Systems Organization

Top Half / Bottom Half Processing 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 (more about this next time) Example: Network card – top half clears card buffer while bottom half processes and routes packets CSE 422S – Operating Systems Organization

Hardware Interrupt Implementation Sequence of events on ARM: Someone registers a handler on specific IRQ line Device raises interrupt line with GIC (Generic Interrupt Controller) 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() (architecture independent, found in kernel/irq/irqdesc.c) Proceeds to specific handlers from there Returns after executing all handlers CSE 422S – Operating Systems Organization