SlideShare ist ein Scribd-Unternehmen logo
1 von 14
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Interrupt Management
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
What to Expect
●
Need for interrupts
●
IRQ numbers
●
Interrupt Registration
●
SoftIRQ
●
Tasklets
●
Work Queues
●
Threaded Irq handling
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Need for interrupts
●
Interrupt is the intervention
●
Interrupt is the mechanism to get the immediate
CPU attention
●
Speed mismatch between CPU & the periperal
devices
●
Avoiding the polling for better effieciency
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
How interrupts work?
●
Whenever there is a change in the hardware
state, CPU is interrupted
●
The ISR is invoked to service the interrupts
●
Typically process has very few interrupts
– So, the processor is occompanied with interrupt
controller to service various interrupts
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Interrupt Request (IRQ)
●
Number for which the ISR is registered
●
Depends on the SOC & connections on the board
●
So, its part of Board Support Packages (BSP)
●
Linux uses the Virtual IRQ numbers
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Interrupt Registration API
●
int request_irq(unsigned int irq, irq_handler_t
handler, unsigned long flags, const char *name,
void *dev_id);
– typedef irqreturn_t (*irq_handler_t)(int, void *);
●
void free_irq(unsigned int irq, void *dev_id);
●
Flags
– IRQF_TRIGGER_RISING, ..., IRQF_TRIGGER_HIGH, ...
– IRQF_SAMPLE_RANDOM
– IRQF_SHARED, ...
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Soft IRQ
●
Triggered by Sotware
●
Basic bottom half
●
Also, known as synchronous interrupts
– HI_SOFTIRQ=0,
– TIMER_SOFTIRQ,
– NET_TX_SOFTIRQ,
– NET_RX_SOFTIRQ,
– BLOCK_SOFTIRQ,
– IRQ_POLL_SOFTIRQ,
– TASKLET_SOFTIRQ,
– SCHED_SOFTIRQ,
– HRTIMER_SOFTIRQ,
– RCU_SOFTIRQ,
– NR_SOFTIRQS
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Tasklets
●
One of the bottom halves
●
Takes up the remaining portion of the
processing left over by ISR
●
Executes in the software interrupt context
●
Sleeping is not allowed
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Tasklet Data Structures
●
struct tasklet_struct
●
void tasklet_init(struct tasklet_struct *t, void (*func)
(unsigned long), unsigned long data);
●
DECLARE_TASKLET(name, func, data);
●
DECLARE_TASKLET_DISABLED(name, func, data);
●
tasklet_enable(t); tasklet_disable(t);
●
tasklet_disable_nosync(t);
●
tasklet_[hi_]schedule(t);
●
tasklet_kill(t);
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Work Queues
●
Bottom half, similar to tasklet
●
Does the remaining portion of task
●
Executes in the special kernel thread
●
Can sleep or block
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Work Queue APIs
●
struct workqueue_struct, struct work_struct
●
Create Work Queue
– q = create_workqueue(name);
– q = create_singlethread_workqueue(name);
●
Destroy Work Queue
– flush_workqueue(q);
– destroy_workqueue(q);
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Work Queue APIs
●
Initializing the Work
– DECLARE_WORK(w, void (*function)(struct work_struct *));
– INIT_WORK(w, void (*function)(struct work_struct *));
●
Scheduling the work
– int queue_work(q, &w);
– int queue_delayed_work(q, &w, d);
●
Cancelling the work
– int cancel_delayed_work(&w);
●
Shared Work queue
– schedule_work(&w)
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
Threaded IRQ
●
Reduce the time spent in ISR
●
Similar to Tasklets & Work Queues, but
simplifies the registration & scheduling
●
Runs in kernel thread with pre-emption enabled
●
Suitable for scenarios where long processing
needs to be done
●
API
– Int request_threaded_irq(unsigned int irq,
irq_handler_t thread_fn, unsigned long flags, const
char *name, void *dev)
@ 2021-21 Embitude Trainings <info@embitude.in>
All Rights Reserved
What all did we learn?
●
Need for interrupts
●
IRQ numbers
●
Interrupt Registration
●
SoftIRQ
●
Tasklets
●
Work Queues
●
Threaded Irq handling

Weitere ähnliche Inhalte

Kürzlich hochgeladen

2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 

Kürzlich hochgeladen (20)

2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 

Empfohlen

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Empfohlen (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Linux Interrupt Management

  • 1. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Interrupt Management
  • 2. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved What to Expect ● Need for interrupts ● IRQ numbers ● Interrupt Registration ● SoftIRQ ● Tasklets ● Work Queues ● Threaded Irq handling
  • 3. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Need for interrupts ● Interrupt is the intervention ● Interrupt is the mechanism to get the immediate CPU attention ● Speed mismatch between CPU & the periperal devices ● Avoiding the polling for better effieciency
  • 4. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved How interrupts work? ● Whenever there is a change in the hardware state, CPU is interrupted ● The ISR is invoked to service the interrupts ● Typically process has very few interrupts – So, the processor is occompanied with interrupt controller to service various interrupts
  • 5. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Interrupt Request (IRQ) ● Number for which the ISR is registered ● Depends on the SOC & connections on the board ● So, its part of Board Support Packages (BSP) ● Linux uses the Virtual IRQ numbers
  • 6. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Interrupt Registration API ● int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev_id); – typedef irqreturn_t (*irq_handler_t)(int, void *); ● void free_irq(unsigned int irq, void *dev_id); ● Flags – IRQF_TRIGGER_RISING, ..., IRQF_TRIGGER_HIGH, ... – IRQF_SAMPLE_RANDOM – IRQF_SHARED, ...
  • 7. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Soft IRQ ● Triggered by Sotware ● Basic bottom half ● Also, known as synchronous interrupts – HI_SOFTIRQ=0, – TIMER_SOFTIRQ, – NET_TX_SOFTIRQ, – NET_RX_SOFTIRQ, – BLOCK_SOFTIRQ, – IRQ_POLL_SOFTIRQ, – TASKLET_SOFTIRQ, – SCHED_SOFTIRQ, – HRTIMER_SOFTIRQ, – RCU_SOFTIRQ, – NR_SOFTIRQS
  • 8. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Tasklets ● One of the bottom halves ● Takes up the remaining portion of the processing left over by ISR ● Executes in the software interrupt context ● Sleeping is not allowed
  • 9. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Tasklet Data Structures ● struct tasklet_struct ● void tasklet_init(struct tasklet_struct *t, void (*func) (unsigned long), unsigned long data); ● DECLARE_TASKLET(name, func, data); ● DECLARE_TASKLET_DISABLED(name, func, data); ● tasklet_enable(t); tasklet_disable(t); ● tasklet_disable_nosync(t); ● tasklet_[hi_]schedule(t); ● tasklet_kill(t);
  • 10. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Work Queues ● Bottom half, similar to tasklet ● Does the remaining portion of task ● Executes in the special kernel thread ● Can sleep or block
  • 11. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Work Queue APIs ● struct workqueue_struct, struct work_struct ● Create Work Queue – q = create_workqueue(name); – q = create_singlethread_workqueue(name); ● Destroy Work Queue – flush_workqueue(q); – destroy_workqueue(q);
  • 12. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Work Queue APIs ● Initializing the Work – DECLARE_WORK(w, void (*function)(struct work_struct *)); – INIT_WORK(w, void (*function)(struct work_struct *)); ● Scheduling the work – int queue_work(q, &w); – int queue_delayed_work(q, &w, d); ● Cancelling the work – int cancel_delayed_work(&w); ● Shared Work queue – schedule_work(&w)
  • 13. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved Threaded IRQ ● Reduce the time spent in ISR ● Similar to Tasklets & Work Queues, but simplifies the registration & scheduling ● Runs in kernel thread with pre-emption enabled ● Suitable for scenarios where long processing needs to be done ● API – Int request_threaded_irq(unsigned int irq, irq_handler_t thread_fn, unsigned long flags, const char *name, void *dev)
  • 14. @ 2021-21 Embitude Trainings <info@embitude.in> All Rights Reserved What all did we learn? ● Need for interrupts ● IRQ numbers ● Interrupt Registration ● SoftIRQ ● Tasklets ● Work Queues ● Threaded Irq handling