Whether we can use semaphore or mutex or spinlock in interrupt context in linux kernel?
Answer / Parmanand Singh
In Linux Kernel, neither semaphores nor mutexes nor spinlocks should be used directly within an interrupt handler. This is because the preempt_disable() function is typically called when entering an interrupt handler to prevent the scheduler from preempting the current task. However, if preempt_disable() is called, it disables all kernel preemption including mutexes and semaphores. Spinlocks can be used in interrupt handlers because they do not involve a context switch and thus no mutex or semaphore would be affected.
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain scope of static variables?
Explain interrupt latency and how can we decrease it?
What's the difference between locking and lockless (optimistic and pessimistic) concurrency models?
What are the languages used in embedded system?
Tell me how are macros different from inline functions?
What kinds of problems can you hit with locking model?
Implement a <basic data structure> using <some language> on <paper|whiteboard|notepad>.
What is isr? Can they be passed any parameter and can they return a value?
How does the interrupt architecture works?
Tell me what is interrupt latency?
Have you designed ui, user interface?
What is the repository pattern? The factory pattern? Why are patterns important?