Covers the basic of interrupt handling, Interrupt Request Number (IRQ), registering the interrupts handler in Linux device driver, registering the bottom halves, tasklets, work queues, threaded irq handler
Covers the basic of interrupt handling, Interrupt Request Number (IRQ), registering the interrupts handler in Linux device driver, registering the bottom halves, tasklets, work queues, threaded irq handler
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
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
Il semblerait que vous ayez déjà ajouté cette diapositive à .
Créer un clipboard
Vous avez clippé votre première diapositive !
En clippant ainsi les diapos qui vous intéressent, vous pourrez les revoir plus tard. Personnalisez le nom d’un clipboard pour mettre de côté vos diapositives.
Créer un clipboard
Partager ce SlideShare
Vous avez les pubs en horreur?
Obtenez SlideShare sans publicité
Bénéficiez d'un accès à des millions de présentations, documents, e-books, de livres audio, de magazines et bien plus encore, sans la moindre publicité.
Offre spéciale pour les lecteurs de SlideShare
Juste pour vous: Essai GRATUIT de 60 jours dans la plus grande bibliothèque numérique du monde.
La famille SlideShare vient de s'agrandir. Profitez de l'accès à des millions de livres numériques, livres audio, magazines et bien plus encore sur Scribd.
Apparemment, vous utilisez un bloqueur de publicités qui est en cours d'exécution. En ajoutant SlideShare à la liste blanche de votre bloqueur de publicités, vous soutenez notre communauté de créateurs de contenu.
Vous détestez les publicités?
Nous avons mis à jour notre politique de confidentialité.
Nous avons mis à jour notre politique de confidentialité pour nous conformer à l'évolution des réglementations mondiales en matière de confidentialité et pour vous informer de la manière dont nous utilisons vos données de façon limitée.
Vous pouvez consulter les détails ci-dessous. En cliquant sur Accepter, vous acceptez la politique de confidentialité mise à jour.