BUS ARBITRATION AND SHARED MEMORY
4 - 22
PORT A
MOTOROLA
4.7.4
Signaling Using Semaphores
Figure 4-17 shows a more sophisticated shared memory system that uses external arbi-
tration with both local external memory and shared memory. The four semaphores are
bits in one of the words in each shared memory bank used by software to arbitrate mem-
ory use. Semaphores are commonly used to indicate that the contents of the sema-
phore’s memory blocks are being used by one processor and are not available for use by
another processor. Typically, if the semaphore is cleared, the block is not allocated to a
processor; if the semaphore is set, the block is allocated to a processor.
Without semaphores, one processor may try to use data while it is being changed by
another processor, which may cause errors. This problem can occur in a shared memory
system when separate test and set instructions are used to “lock” a data block for use by
a single processor.
The correct procedure is to test the semaphore and then set the semaphore if it was
clear to lock and gain exclusive use of the data block. The problem occurs when the sec-
ond processor acquires the bus and tests the semaphore after the first processor tests
the semaphore but before the first processor can lock the data block. The incorrect
sequence is:
1. the first processor tests the semaphore and sees that the block is available
2. the second processor then tests the bit and also sees that the block is available
3. both processors then set the bit to lock the data
4. both proceed to use the data on the assumption that the data cannot be
changed by another processor
BS
WT
BR
BG
1
2
3
Figure 4-16 Two DSPs with External Bus Arbitration Timing
DATA TRANSFERRED
BETWEEN DSP#1
AND MEMORY HERE
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
.
..