Chapter 11
286 MIPS R4000 Microprocessor User's Manual
11.12 R4000 Processor Synchronization Support
In a multiprocessor system, it is essential that two or more processors
working on a common task execute without corrupting each other’s
subtasks. Synchronization, an operation that guarantees an orderly access
to shared memory, must be implemented for a properly functioning
multiprocessor system. Two of the more widely used methods are
discussed in this section: test-and-set, and counter.
Test-and-Set (Spinlock)
Test-and-set
†
uses a variable called the semaphore, which protects data
from being simultaneously modified by more than one processor.
In other words, a processor can lock out other processors from accessing
shared data when the processor is in a critical section, a part of program in
which no more than a fixed number of processors is allowed to execute. In
the case of test-and-set, only one processor can enter the critical section.
Figure 11-16 illustrates a test-and-set synchronization procedure that uses
a semaphore; when the semaphore is set to 0, the shared data is unlocked,
and when the semaphore is set to 1, the shared data is locked.
† Test-and-set is sometimes referred to as spinlock.