Chapter 10 XGATE (S12XGATEV3)
MC9S12XE-Family Reference Manual , Rev. 1.19
Freescale Semiconductor
375
Figure 10-24. Semaphore State Transitions
gives an example of the typical usage of the XGATE hardware semaphores.
Two concurrent threads are running on the system. One is running on the S12X_CPU and the other is
running on the RISC core. They both have a critical section of code that accesses the same system resource.
To guarantee that the system resource is only accessed by one thread at a time, the critical code sequence
must be embedded in a semaphore lock/release sequence as shown.
UNLOCKED
LOCKED BY
S12X_CPU
LOCKED BY
XGATE
set_xgsem
: 1 is written to XGSEM[
n
] (and 1 is written to XGSEMM[
n
])
clr_xgsem
: 0 is written to XGSEM[
n
] (and 1 is written to XGSEMM[
n
])
ssem
:
Executing SSEM instruction (on semaphore
n
)
csem
:
Executing CSEM instruction (on semaphore
n
)
clr_xgsem
csem
ssem & set_xgsem
clr_xgsem
ssem &
set_xgsem
csem
ssem
Because
of
an
order
from
the
United
States
International
Trade
Commission,
BGA-packaged
product
lines
and
part
numbers
indicated
here
currently
are
not
available
from
Freescale
for
import
or
sale
in
the
United
States
prior
to
September
2010:
S12XE
products
in
208
MAPBGA
packages