SlideShare a Scribd company logo
1 of 18
© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Interrupts
2© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
W's & How's of Interrupts?
The IRQ
Interrupt Handling & Handlers
Soft IRQs
3© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
W's of an Interrupt?
What is an Interrupt?
Intervention to get Attention
Here, from the Devices to the CPU
Why is an Interrupt required?
Mismatch of Device & CPU speeds
Get overall better efficiency & latency
4© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
How does interrupt work?
Interrupt is a Hardware thing
It needs Physical connection
In Processors
Typically have one or two interrupt lines
Handled by a Interrupt Controller, called PIC
And PIC informs the Processor through its one line
In Micro-controllers
Each GPIO can act as an interrupt line
Interrupt Controller is in-built
In both cases, the CPU then decodes the IRQ
And calls the corresponding registered interrupt handler
5© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Interrupt ReQuest (IRQ)
Number derived by CPU & Board
Programmed or Hard Coded with Interrupt Controller
Hence, one key component of LSPs
In x86
CPU Specific: 0x00 to 0x1F (Hard coded)
Board Specific: 0x20 to 0xFF
Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h
In Microcontrollers
Depends on the controller
Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h
6© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Programming Interface
Header: <asm/interrupt.h>
Type:
typedef irqreturn_t (*irq_handler_t)(int, void *);
APIs
int request_irq(unsigned int irq, irq_handler_t handler, unsigned long
flags, const char *name, void *dev_id);
void free_irq(unsigned int irq, void *dev_id);
int can_request_irq(irq, flags);
Flags
IRQF_TRIGGER_RISING, ..., IRQF_TRIGGER_HIGH, ...
IRQF_SAMPLE_RANDOM
IRQF_SHARED, ...
7© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
IRQ Handler Do's & Don'ts
No sleeping – direct or indirect
Example: schedule_timeout, input_register_device
No mutexes
Rather use spin_locks, if you must
Can't exchange data with User Space
In their own context. current is invalid
If lot to be done, break it into two
Top Half & Bottom Half
Need not be re-entrant
May get interrupted by higher priority interrupt handlers
8© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
The Additional Info
IRQ Control
enable_irq(irq);
disable_irq(irq);
IRQ Handler returns
IRQ_NONE
IRQ_HANDLED
Check for execution state
in_interrupt();
Synchronous interrupts, treated alike
Exceptions to report grave runtime errors
Software interrupts such as the int 0x80 used for system calls in x86
architecture
9© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Message Signaled Interrupts
Specifically for PCI Devices
Advantages
No sharing, No sync issues, More interrupts
Modes: MSI or MSI-X (only one at a time)
MSI (since PCI 2.2)
Special Address: PCI config space
Interrupts / Device: Upto 32 in powers of 2
MSI-X (since PCI 3.0)
Special Address: Bus address
Interrupts / Device: Sparse & upto 2048
10© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
MSI/MSI-X APIs
MSI
int pci_enable_msi(strcut pci_dev *);
int pci_enable_msi_block(strcut pci_dev *, int cnt);
void pci_disable_msi(strcut pci_dev *);
MSI-X
int pci_enable_msix(strcut pci_dev *, struct
msix_entry *, int nvec);
struct msix_entry
{ u16 vector /* allocated irq */, entry; };
void pci_disable_msix(strcut pci_dev *);
11© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Soft IRQs
12© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What is a Soft IRQ?
Basic Bottom Half
Synchronous Interrupt
Have strong locking requirements
Used for the performance sensitive subsystems
Not same as Software Interrupt
13© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Typical Soft IRQs
Timer
Network
Block
Tasklet
Scheduler
High Resolution Timer
14© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Linux Execution Model
Interrupt Handlers
Soft IRQ Handlers
Kernel Threads
Timer Network...
Timer Network...Scheduler
...
User Processes
Work Q
Kernel
Thread
User Process
Pn
User Process
P1
...
15© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Programming
Header: <linux/interrupt.h>
APIs
void open_softirq(int nr, void (*action)(struct
softirq_action *));
void raise_softirq(unsigned int nr);
16© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Top & Bottom Halves
Top Half
Registered through request_irq
Bottom Half
Tasklet
Soft IRQ Context
Fast & Atomic
Only different tasklets can run on different CPUs
Work Queue
Special Kernel Process Context
Allowed to sleep
Can run simultaneously on different CPUs
17© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
W's & How's of Interrupts?
The IRQ
Interrupt Handling & Handlers
Message Signalled Interrupts
Soft IRQs: The Bottom Halves
18© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?

More Related Content

What's hot

U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New HardwareRuggedBoardGroup
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device driversHoucheng Lin
 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Aananth C N
 
Part-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver developmentPart-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver developmentFastBit Embedded Brain Academy
 
Quick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOQuick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOChris Simmonds
 
Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development FastBit Embedded Brain Academy
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral InterfaceAnurag Tomar
 
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingPART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingFastBit Embedded Brain Academy
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 

What's hot (20)

Spi drivers
Spi driversSpi drivers
Spi drivers
 
Platform Drivers
Platform DriversPlatform Drivers
Platform Drivers
 
Network Drivers
Network DriversNetwork Drivers
Network Drivers
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Block Drivers
Block DriversBlock Drivers
Block Drivers
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
axi protocol
axi protocolaxi protocol
axi protocol
 
Virtualization Support in ARMv8+
Virtualization Support in ARMv8+Virtualization Support in ARMv8+
Virtualization Support in ARMv8+
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Introduction to stm32-part2
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
What is Bootloader???
What is Bootloader???What is Bootloader???
What is Bootloader???
 
Part-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver developmentPart-2: Mastering microcontroller with embedded driver development
Part-2: Mastering microcontroller with embedded driver development
 
Quick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOQuick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIO
 
Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development Part-1 : Mastering microcontroller with embedded driver development
Part-1 : Mastering microcontroller with embedded driver development
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with DebuggingPART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
PART-2 : Mastering RTOS FreeRTOS and STM32Fx with Debugging
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
 

Viewers also liked (16)

Serial Drivers
Serial DriversSerial Drivers
Serial Drivers
 
File System Modules
File System ModulesFile System Modules
File System Modules
 
USB Drivers
USB DriversUSB Drivers
USB Drivers
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
References
ReferencesReferences
References
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Low-level Accesses
Low-level AccessesLow-level Accesses
Low-level Accesses
 
Kernel Programming
Kernel ProgrammingKernel Programming
Kernel Programming
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
BeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM Bootloaders
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
File Systems
File SystemsFile Systems
File Systems
 

Similar to Interrupts

IRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleIRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleAlison Chaiken
 
MICROCONTROLLER PROGRAMMING.pdf
MICROCONTROLLER PROGRAMMING.pdfMICROCONTROLLER PROGRAMMING.pdf
MICROCONTROLLER PROGRAMMING.pdfKarthiA15
 
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWERMastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWERFastBit Embedded Brain Academy
 
With suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerruptsWith suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerruptsransherraj
 
Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...
Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...
Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...Intel® Software
 
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner FischerOSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner FischerNETWAYS
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
리눅스 드라이버 #2
리눅스 드라이버 #2리눅스 드라이버 #2
리눅스 드라이버 #2Sangho Park
 
Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...
Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...
Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...Kuniyasu Suzaki
 
IRJET- Design of Low Power 32- Bit RISC Processor using Verilog HDL
IRJET-  	  Design of Low Power 32- Bit RISC Processor using Verilog HDLIRJET-  	  Design of Low Power 32- Bit RISC Processor using Verilog HDL
IRJET- Design of Low Power 32- Bit RISC Processor using Verilog HDLIRJET Journal
 
리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3Sangho Park
 

Similar to Interrupts (20)

Signals
SignalsSignals
Signals
 
SR-IOV Introduce
SR-IOV IntroduceSR-IOV Introduce
SR-IOV Introduce
 
IRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleIRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the Preemptible
 
MICROCONTROLLER PROGRAMMING.pdf
MICROCONTROLLER PROGRAMMING.pdfMICROCONTROLLER PROGRAMMING.pdf
MICROCONTROLLER PROGRAMMING.pdf
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Rsockets ofa12
Rsockets ofa12Rsockets ofa12
Rsockets ofa12
 
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWERMastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
 
Embedded Software Design
Embedded Software DesignEmbedded Software Design
Embedded Software Design
 
Kernel Timing Management
Kernel Timing ManagementKernel Timing Management
Kernel Timing Management
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Training report on embedded sys_AVR
Training report on embedded sys_AVRTraining report on embedded sys_AVR
Training report on embedded sys_AVR
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
With suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerruptsWith suitable diagram explain the working of 8255 a and inerrupts
With suitable diagram explain the working of 8255 a and inerrupts
 
Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...
Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...
Simple Single Instruction Multiple Data (SIMD) with the Intel® Implicit SPMD ...
 
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner FischerOSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
리눅스 드라이버 #2
리눅스 드라이버 #2리눅스 드라이버 #2
리눅스 드라이버 #2
 
Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...
Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...
Kernel Memory Protection by an Insertable Hypervisor which has VM Introspec...
 
IRJET- Design of Low Power 32- Bit RISC Processor using Verilog HDL
IRJET-  	  Design of Low Power 32- Bit RISC Processor using Verilog HDLIRJET-  	  Design of Low Power 32- Bit RISC Processor using Verilog HDL
IRJET- Design of Low Power 32- Bit RISC Processor using Verilog HDL
 
리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3
 

More from Anil Kumar Pugalia (20)

File System Modules
File System ModulesFile System Modules
File System Modules
 
Processes
ProcessesProcesses
Processes
 
System Calls
System CallsSystem Calls
System Calls
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Playing with R L C Circuits
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C Circuits
 
Mobile Hacking using Linux Drivers
Mobile Hacking using Linux DriversMobile Hacking using Linux Drivers
Mobile Hacking using Linux Drivers
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISP
 
Power of vi
Power of viPower of vi
Power of vi
 
"make" system
"make" system"make" system
"make" system
 
Hardware Design for Software Hackers
Hardware Design for Software HackersHardware Design for Software Hackers
Hardware Design for Software Hackers
 
RPM Building
RPM BuildingRPM Building
RPM Building
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
 
System Calls
System CallsSystem Calls
System Calls
 
Timers
TimersTimers
Timers
 
Threads
ThreadsThreads
Threads
 
Processes
ProcessesProcesses
Processes
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Linux File System
Linux File SystemLinux File System
Linux File System
 

Recently uploaded

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Recently uploaded (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Interrupts

  • 1. © 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Interrupts
  • 2. 2© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? W's & How's of Interrupts? The IRQ Interrupt Handling & Handlers Soft IRQs
  • 3. 3© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. W's of an Interrupt? What is an Interrupt? Intervention to get Attention Here, from the Devices to the CPU Why is an Interrupt required? Mismatch of Device & CPU speeds Get overall better efficiency & latency
  • 4. 4© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. How does interrupt work? Interrupt is a Hardware thing It needs Physical connection In Processors Typically have one or two interrupt lines Handled by a Interrupt Controller, called PIC And PIC informs the Processor through its one line In Micro-controllers Each GPIO can act as an interrupt line Interrupt Controller is in-built In both cases, the CPU then decodes the IRQ And calls the corresponding registered interrupt handler
  • 5. 5© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Interrupt ReQuest (IRQ) Number derived by CPU & Board Programmed or Hard Coded with Interrupt Controller Hence, one key component of LSPs In x86 CPU Specific: 0x00 to 0x1F (Hard coded) Board Specific: 0x20 to 0xFF Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h In Microcontrollers Depends on the controller Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h
  • 6. 6© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Programming Interface Header: <asm/interrupt.h> Type: typedef irqreturn_t (*irq_handler_t)(int, void *); APIs int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev_id); void free_irq(unsigned int irq, void *dev_id); int can_request_irq(irq, flags); Flags IRQF_TRIGGER_RISING, ..., IRQF_TRIGGER_HIGH, ... IRQF_SAMPLE_RANDOM IRQF_SHARED, ...
  • 7. 7© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. IRQ Handler Do's & Don'ts No sleeping – direct or indirect Example: schedule_timeout, input_register_device No mutexes Rather use spin_locks, if you must Can't exchange data with User Space In their own context. current is invalid If lot to be done, break it into two Top Half & Bottom Half Need not be re-entrant May get interrupted by higher priority interrupt handlers
  • 8. 8© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. The Additional Info IRQ Control enable_irq(irq); disable_irq(irq); IRQ Handler returns IRQ_NONE IRQ_HANDLED Check for execution state in_interrupt(); Synchronous interrupts, treated alike Exceptions to report grave runtime errors Software interrupts such as the int 0x80 used for system calls in x86 architecture
  • 9. 9© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Message Signaled Interrupts Specifically for PCI Devices Advantages No sharing, No sync issues, More interrupts Modes: MSI or MSI-X (only one at a time) MSI (since PCI 2.2) Special Address: PCI config space Interrupts / Device: Upto 32 in powers of 2 MSI-X (since PCI 3.0) Special Address: Bus address Interrupts / Device: Sparse & upto 2048
  • 10. 10© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. MSI/MSI-X APIs MSI int pci_enable_msi(strcut pci_dev *); int pci_enable_msi_block(strcut pci_dev *, int cnt); void pci_disable_msi(strcut pci_dev *); MSI-X int pci_enable_msix(strcut pci_dev *, struct msix_entry *, int nvec); struct msix_entry { u16 vector /* allocated irq */, entry; }; void pci_disable_msix(strcut pci_dev *);
  • 11. 11© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Soft IRQs
  • 12. 12© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What is a Soft IRQ? Basic Bottom Half Synchronous Interrupt Have strong locking requirements Used for the performance sensitive subsystems Not same as Software Interrupt
  • 13. 13© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Typical Soft IRQs Timer Network Block Tasklet Scheduler High Resolution Timer
  • 14. 14© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Linux Execution Model Interrupt Handlers Soft IRQ Handlers Kernel Threads Timer Network... Timer Network...Scheduler ... User Processes Work Q Kernel Thread User Process Pn User Process P1 ...
  • 15. 15© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Programming Header: <linux/interrupt.h> APIs void open_softirq(int nr, void (*action)(struct softirq_action *)); void raise_softirq(unsigned int nr);
  • 16. 16© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Top & Bottom Halves Top Half Registered through request_irq Bottom Half Tasklet Soft IRQ Context Fast & Atomic Only different tasklets can run on different CPUs Work Queue Special Kernel Process Context Allowed to sleep Can run simultaneously on different CPUs
  • 17. 17© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? W's & How's of Interrupts? The IRQ Interrupt Handling & Handlers Message Signalled Interrupts Soft IRQs: The Bottom Halves
  • 18. 18© 2010-15 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?