Wednesday, April 10, 2013

Locking in Linux SMP - When to use what?

  • For kernels compiled without CONFIG_SMP, and without CONFIG_PREEMPT spinlocks do not exist at all.
  • If the kernel is compiled without CONFIG_SMP, but CONFIG_PREEMPT is set, then spinlocks simply disable preemption, which is sufficient to prevent any races.
  • Remember the advice above: you can always use spin_lock_irqsave(), which is a superset of all other spinlock primitives.


Post a Comment