This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Your synchronization method is valid; the PCIe write posting rules are designed to allow a producer-consumer relationship like yours.
(Please note that the memory must not be cached.)
Polling memory to wait for changes eats power, so in practice, this is usually combined with an interrupt (device → host) or a register write (host → device) to tell the other side to wake up.
Individual read or write operations are atomic.
However, in the general case, when you do a read and then a write, it is possible for someone else to write another value between these two operations.
In your case, if one side only changes 0 to 1, and the other side only changes 1 to 0, this conflict cannot happen.