To control access to data structures that are shared between them, threads and processes use the standard POSIX primitives of mutexes, condvars, and semaphores. These work without change in an SMP system.
Many realtime systems also need to protect access to shared data structures between an interrupt handler and the thread that owns the handler. The traditional POSIX primitives used between threads aren't available for use by an interrupt handler. There are two solutions here:
The thread on a non-SMP system protects itself with code of the form:
InterruptDisable() // critical section InterruptEnable()
Or:
InterruptMask(intr) // critical section InterruptUnmask(intr)
Unfortunately, this code will fail on an SMP system since the thread may be running on one processor while the interrupt handler is concurrently running on another processor!
One solution would be to lock the thread to a particular processor (see Bound Multiprocessing (BMP), later in this chapter).
A better solution would be to use a new exclusion lock available to both the thread and the interrupt handler. This is provided by the following primitives, which work on both uniprocessor and SMP machines:
On a non-SMP system, there's no need for a spinlock.
For more information, see the Multicore Processing chapter of the QNX Neutrino Programmer's Guide.