Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6333

What happens when a task is executing critical section but it needs to be scheduled out on a uniprocessor system with preemption disabled?

$
0
0

Here is a scenario. Let’s say that a kernel task is running on a uniprocessor system with preemption disabled. The task acquires a spin lock. Now it is executing it’s critical section. At this time, what if the time slice available for this task expires and it has to schedule out?

  1. Does the spin_lock have a mechanism to prevent this?
  2. Can it be scheduled out? If yes, then what happens to the critical section?
  3. Can it be interrupted by an IRQ? (Assuming that preemption is disabled)
  4. Is this scenario feasible? In other words, could this scenario happen?

From the kernel code, I understand that the spin_lock is basically a nop on a uniprocessor with preemption disabled. To be accurate, all it does is barrier()I understand why it is a nop (as it is a uniprocessor and no other task could be manipulating the data at that instant) but I still don’t understand how it could be uninterrupted(due to IRQs or scheduling).What am I missing here? Pointers to the Linux kernel code which indicates about this could be really helpful.

My basic assumptions:

32 bit Linux kernel


Viewing all articles
Browse latest Browse all 6333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>