mirror of https://github.com/tLDP/LDP
40 lines
2.4 KiB
Plaintext
40 lines
2.4 KiB
Plaintext
<sect1><title>Symmetrical Multi-Processing</title>
|
|
|
|
<indexterm><primary>SMP</primary></indexterm>
|
|
<indexterm><primary>multi-processing</primary></indexterm>
|
|
<indexterm><primary>symmetrical multi-processing</primary></indexterm>
|
|
<indexterm><primary>processing</primary><secondary>multi</secondary></indexterm>
|
|
<indexterm><primary>CPU</primary><secondary>multiple</secondary></indexterm>
|
|
|
|
<para>One of the easiest and cheapest ways to improve hardware performance is to put more than one CPU on the board. This can
|
|
be done either making the different CPU's take on different jobs (asymmetrical multi-processing) or by making them all run in
|
|
parallel, doing the same job (symmetrical multi-processing, a.k.a. SMP). Doing asymmetrical multi-processing effectively
|
|
requires specialized knowledge about the tasks the computer should do, which is unavailable in a general purpose operating
|
|
system such as Linux. On the other hand, symmetrical multi-processing is relatively easy to implement.</para>
|
|
|
|
<para>By relatively easy, I mean exactly that: not that it's <emphasis>really</emphasis> easy. In a symmetrical
|
|
multi-processing environment, the CPU's share the same memory, and as a result code running in one CPU can affect the memory
|
|
used by another. You can no longer be certain that a variable you've set to a certain value in the previous line still has
|
|
that value; the other CPU might have played with it while you weren't looking. Obviously, it's impossible to program like
|
|
this.</para>
|
|
|
|
<para>In the case of process programming this normally isn't an issue, because a process will normally only run on one CPU at
|
|
a time<footnote><para>The exception is threaded processes, which can run on several CPU's at once.</para></footnote>. The
|
|
kernel, on the other hand, could be called by different processes running on different CPU's.</para>
|
|
|
|
<para>In version 2.0.x, this isn't a problem because the entire kernel is in one big spinlock. This means that if one CPU is
|
|
in the kernel and another CPU wants to get in, for example because of a system call, it has to wait until the first CPU is
|
|
done. This makes Linux SMP safe<footnote><para>Meaning it is safe to use it with SMP</para></footnote>, but
|
|
inefficient.</para>
|
|
|
|
<para>In version 2.2.x, several CPU's can be in the kernel at the same time. This is something module writers need to be
|
|
aware of.</para>
|
|
|
|
</sect1>
|
|
|
|
|
|
|
|
<!--
|
|
vim: tw=128
|
|
-->
|