Whether we can use semaphore or mutex or spinlock in interrupt context in linux kernel?



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

Post New Answer

More Embedded Systems AllOther Interview Questions

Explain scope of static variables?

1 Answers  


Explain interrupt latency and how can we decrease it?

1 Answers  


What's the difference between locking and lockless (optimistic and pessimistic) concurrency models?

1 Answers  


What are the languages used in embedded system?

1 Answers  


Tell me how are macros different from inline functions?

1 Answers  


What kinds of problems can you hit with locking model?

1 Answers  


Implement a <basic data structure> using <some language> on <paper|whiteboard|notepad>.

1 Answers  


What is isr? Can they be passed any parameter and can they return a value?

1 Answers  


How does the interrupt architecture works?

1 Answers  


Tell me what is interrupt latency?

1 Answers  


Have you designed ui, user interface?

1 Answers  


What is the repository pattern? The factory pattern? Why are patterns important?

1 Answers  


Categories