Spinlocks are so called "busy-wait"
locking mechanisms used in software
(most notably operating systems'
kernels and other applications that
need to address the CPU and/or other
hardware directly) to ensure
mutual exclusion for a resource.
A process that needs exclusive
access to, say, a certain hardware
register locks the spinlock associated
with that particular register,
does its work, and unlocks it again
afterwards.
Tasks waiting for a spinlock are
suspended in a busy loop until the
spinlock becomes available again.
Spinlocks are only really useful in
SMP (multiprocessor) machines;
their sole advantage over other
locking mechanisms is that it
blocks IRQs only on the processor
the task is running on. Single
processor systems usually use
a so-called cli/sti pair instead.
(cli/sti refers to their respective
assembler instructions CLI -
Clear Interrupt Enable Flag, and
STI, Set Interrupt Enable Flag.)
Spinlocks come in two flavors;
full locks and read-write locks.
The latter can be used to allow
multiple readers of a register,
while only one process at a time
can write to it.
Sources: the Linux kernel
source, and http://kernelnewbies.org/