1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Locks and Uniprocessor Kernels</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Unreliable Guide To Locking"><link rel="up" href="locks.html" title="Chapter&#160;3.&#160;Locking in the Linux Kernel"><link rel="prev" href="locks.html" title="Chapter&#160;3.&#160;Locking in the Linux Kernel"><link rel="next" href="usercontextlocking.html" title="Locking Only In User Context"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Locks and Uniprocessor Kernels</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="locks.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;3.&#160;Locking in the Linux Kernel</th><td width="20%" align="right">&#160;<a accesskey="n" href="usercontextlocking.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="uniprocessor"></a>Locks and Uniprocessor Kernels</h2></div></div></div><p>
2      For kernels compiled without <span class="symbol">CONFIG_SMP</span>, and
3      without <span class="symbol">CONFIG_PREEMPT</span> spinlocks do not exist at
4      all.  This is an excellent design decision: when no-one else can
5      run at the same time, there is no reason to have a lock.
6    </p><p>
7      If the kernel is compiled without <span class="symbol">CONFIG_SMP</span>,
8      but <span class="symbol">CONFIG_PREEMPT</span> is set, then spinlocks
9      simply disable preemption, which is sufficient to prevent any
10      races.  For most purposes, we can think of preemption as
11      equivalent to SMP, and not worry about it separately.
12    </p><p>
13      You should always test your locking code with <span class="symbol">CONFIG_SMP</span>
14      and <span class="symbol">CONFIG_PREEMPT</span> enabled, even if you don't have an SMP test box, because it
15      will still catch some kinds of locking bugs.
16    </p><p>
17      Mutexes still exist, because they are required for
18      synchronization between <a class="firstterm" href="glossary.html#gloss-usercontext"><em class="firstterm">user 
19      contexts</em></a>, as we will see below.
20    </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="locks.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="locks.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="usercontextlocking.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;3.&#160;Locking in the Linux Kernel&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Locking Only In User Context</td></tr></table></div></body></html>
21