http://lxr.linux.no/linux+v2.6.35/include/linux/preempt.h#L21
I am just trying get the linux source. I saw this preempt count and how does linux ensure the preempt count is atomic ? The code just increments the value.
Also I have an another question. why does interrupt handles need to maintain mutual exclusion. Because only one can execute at a time right ?
Also when interrupts are disabled what does OS do ? Ignore interrups or maintain a queue ?
It increments preempt_count()
- notice the ()
- which is a macro is defined as:
#define preempt_count() (current_thread_info()->preempt_count)
So it is incrementing a per-thread variable, which doesn't require any locking and is safe.
It's best to ask your multiple questions as separate questions, but briefly:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With