This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cortex-A9 accessing atomic variable results in dead loop

I'm using ZYNQ 7000 and implementing a counter in a bare-metal system. A counter in the shared memory is increased by both cores. _Atomic is used so that the 2 cores can be synchronized. But accessing the atomic variable results in dead loop.

The code

The problem I met:

  1. The counter value is only visible to one core. After running IncreaseCounters() in core0, core1 still sees the value 0 in shared memory.
  2. ​The default MMU config is “S=b0 TEX=b100 AP=b11, Domain=b0, C=b1, B=b1" as in translation_table.S. If `Xil_SetTlbAttributes(0xffff0000, 0x14de2)` in xil_mmu.c  is added to make the config "
    S=b1 TEX=b100 AP=b11, Domain=b1111, C=b0, B=b0" as in Xilinx xapp1079, then the counter value is visible to the other core. But the increament of the plain counter is not synchronized. The increment of the atomic counter loops forever. The assembly of `++SHAERD_MEM->atomicCounter` is the following (in which strex always fails):

Is this a config problem of MMU? How can the counter be synchronized in the 2 cores? Thanks very much

0