
Semaphores
PXN20 Microcontroller Reference Manual, Rev. 1
15-12
Freescale Semiconductor
15.4.1
Semaphore Usage
Example 1: Inter-processor communication done with software interrupts and semaphores...
•
The Z0 uses software interrupts to tell the Z6 that new data is available, or the Z6 does the same to
tell the Z0 that there is new data available for transmission.
•
Because only eight software interrupts are available, the user may need RAM locations or
general-purpose registers in the SIU to refine the meaning of the software interrupt.
•
Messages are passed between cores in a defined section of system RAM.
•
Before a core updates a message, it must check the associated semaphore to see if the other core is
in the process of updating the same message. If the RAM not being updated, then the semaphore
must first be locked, then the message can be updated. A software interrupt can be sent to the other
core and the semaphore can be unlocked. If the RAM is being updated, the CPU must wait for the
other core to unlock the semaphore before proceeding with update.
•
Using the same memory location for bidirectional communication might be difficult, so two
one-way message areas might work better.
— For example, if both cores want to update the same location, then the following sequence may
occur.
1. The Z0 locks the semaphore, updates the memory, unlocks the semaphore, and generates a
software interrupt to the Z6.
2. Before the Z6 takes the software interrupt request, it finds the semaphore to be unlocked, so
it writes new data to the memory.
3. The Z6 software interrupt ISR reads the data sent to the Z0, not the data sent from the Z0,
and performs an incorrect operation.
— Semaphores do not prevent this situation from occurring.
Example 2: Coherent read done with semaphores...
•
The Z6 wants to coherently read a section of shared memory.
•
The Z6 should check that the semaphore for the shared memory is not currently set.
•
The Z6 should set the semaphore for the shared memory to prevent the Z0 from updating the shared
memory.
•
The Z6 reads the required data, then unlock the semaphore.
15.5
Initialization Information
The reset state of the semaphores module allows it to begin operation without the need for any further
initialization. All the internal state machines are cleared by any reset event, allowing the module to
immediately begin operation.
15.6
Application Information
In an operational multi-core system, most interactions involving the semaphores module involves reads
and writes to the SEMA4_GATE
n
registers for implementation of the hardware-enforced software gate
functions. Typical code segments for gate functions perform the following operations:
Summary of Contents for PXN2020
Page 1: ...PXN20 Microcontroller Reference Manual Devices Supported PXN2020 PXN2120 PXN20RM Rev 1 06 2011...
Page 42: ...PXN20 Microcontroller Reference Manual Rev 1 lxiv Freescale Semiconductor...
Page 64: ...Introduction PXN20 Microcontroller Reference Manual Rev 1 1 22 Freescale Semiconductor...
Page 112: ...Signal Description PXN20 Microcontroller Reference Manual Rev 1 3 44 Freescale Semiconductor...
Page 118: ...Resets PXN20 Microcontroller Reference Manual Rev 1 4 6 Freescale Semiconductor...
Page 372: ...e200z6 Core Z6 PXN20 Microcontroller Reference Manual Rev 1 13 8 Freescale Semiconductor...
Page 412: ...e200z0 Core Z0 PXN20 Microcontroller Reference Manual Rev 1 14 14 Freescale Semiconductor...
Page 821: ...Media Local Bus MLB PXN20 Microcontroller Reference Manual Rev 1 Freescale Semiconductor 27 49...
Page 822: ...Media Local Bus MLB PXN20 Microcontroller Reference Manual Rev 1 27 50 Freescale Semiconductor...
Page 1376: ...Memory Map PXN20 Microcontroller Reference Manual Rev 1 A 118 Freescale Semiconductor...