Interrupt Mechanism:
1. Interrupt line is asserted
2. CPU halts the current execution and jumps to the interrupt vector table
3. Interrupt vector table has the branching address of the correspnding INTR line
Before the execution of the ISR(Interrupt Service Routine), linux kernel masks that INR line across all the CPU in SMP environment, so that same interrupt does not occur again before current one is over
API to regrister the ISR to kernel: request_irq(interrupt number, flags, dev)
flags - DISABLE_INTERRUPTS -> Disabled all other interrupts on the CPU
- SHARED - IF the interrupt number is shared with other devices
dev - This argument is important if the INTR line is shared, it helps to differentiate different handler functions
In the Linux kernel ISR need not reentrant as INTR line masked
Use spin lock to protect any shared resources
How to synchronize data between 'two interrupts' and 'interrupts and process'.
Between Interrupts: Use spin_locks
'interrupts and process'.: spin_lock_irqsave
Device Driver:
Device Driver
Completions
1. Interrupt line is asserted
2. CPU halts the current execution and jumps to the interrupt vector table
3. Interrupt vector table has the branching address of the correspnding INTR line
Before the execution of the ISR(Interrupt Service Routine), linux kernel masks that INR line across all the CPU in SMP environment, so that same interrupt does not occur again before current one is over
API to regrister the ISR to kernel: request_irq(interrupt number, flags, dev)
flags - DISABLE_INTERRUPTS -> Disabled all other interrupts on the CPU
- SHARED - IF the interrupt number is shared with other devices
dev - This argument is important if the INTR line is shared, it helps to differentiate different handler functions
In the Linux kernel ISR need not reentrant as INTR line masked
Use spin lock to protect any shared resources
How to synchronize data between 'two interrupts' and 'interrupts and process'.
Between Interrupts: Use spin_locks
'interrupts and process'.: spin_lock_irqsave
Device Driver:
Device Driver
Completions
Completions - "wait for completion" barrier APIs - Provide very useful and efficient thread synchronization mechanism where thread has to wait till certain event or task is completed.
Can be used only in process context, as it sleep.
wait_for_completion() calls spin_lock_irq() & spin_unlock_irq().
struct complete;
init_completion(&completion)
wait_for_completion(&complete) - Wait
complete(&complete);
No comments:
Post a Comment