If the program runs fast enough on a single processor, and
has no interactions with other processes, threads, or interrupt
handlers, you should
remove the synchronization primitives and spare yourself their
overhead and complexity.
Some years back, there were those who would argue that Moore's Law
would eventually force all programs into this category.
However, given the cessation in
rate of CPU MIPS and clock-frequency growth in Intel CPUs since the year 2003,
as can be seen in
Figure
increasing performance will increasingly require parallelism.7.4The debate as to whether this new trend will result in single chips
with thousands
of CPUs will not be settled soon, but given that Paul is typing this
sentence on a dual-core laptop, the age of SMP does seem to be upon us.
It is also important to note that Ethernet bandwidth is continuing
to grow, as shown in
Figure
.
This growth will motivate multithreaded servers in order to handle
the communications load.
Please note that this does not mean that you should code each
and every program in a multi-threaded manner.
Again, if a program runs quickly enough on a single processor,
spare yourself the overhead and complexity of SMP synchronization
primitives.
The simplicity of the hash-table lookup code in
Figure
underscores this point.7.5
On the other hand, if you are not in this happy situation, read on!
Paul E. McKenney 2011-12-16