For kernels compiled without CONFIG_SMP
, and
without CONFIG_PREEMPT
spinlocks do not exist at
all. This is an excellent design decision: when no-one else can
run at the same time, there is no reason to have a lock.
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. For most purposes, we can think of preemption as
equivalent to SMP, and not worry about it separately.
You should always test your locking code with CONFIG_SMP
and CONFIG_PREEMPT
enabled, even if you don't have an SMP test box, because it
will still catch some kinds of locking bugs.
Semaphores still exist, because they are required for synchronization between user contexts, as we will see below.