Spinlocks implement a "busy
wait condition" for a resource. If a processor attempts
to obtain a spinlock being held by another processor, it will wait
until the lock is released.
Spinlocks can be acquired on an interrupt stack. A deadlock
can arise, however, if a processor takes an interrupt while holding
a spinlock and the interrupt code tries to acquire the same spinlock.
To prevent this from occurring, HP-UX requires the spl level to
be raised whenever a spinlock is acquired. When the spinlock is
released, the prior spl level is reverted to. Once a spinlock is
acquired, the spl level should not be lowered within the spinlocked
critical section.
Spinlocks are used to synchronize access to data between multiple
processors, and as such, have little value in a uniprocessor system.
Within the kernel the MP_SPINLOCK()
macro checks the uniprocessor flag and returns if not an MP system.