A Race Condition Can Present a Problem
Consider the following possibility:
The task executing on processor 0 reads the semaphore to determine the buffer's availability.
The task tests the semaphore's value and determines that the buffer is available (the semaphore value = zero).
Immediately after the task on processor 0 has completed the memory read to obtain and test the state of the semaphore value, a task executing on processor 1 has initiated a memory read request on the FSB to test the state of the same semaphore. It completes the read and begins testing the value.
The processor 0 task initiates a memory write on the FSB to update the semaphore to a non-zero value to mark the shared buffer as unavailable. After it completes the write, it considers ...
Get The Unabridged Pentium 4 IA32 Processor Genealogy now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.