I have found a couple of ways regarding how to atomically check a register or mem. location and change its value to something else (on x86) but I haven't found anything regarding the following:
Test (atomically) a memory location (which is used as flag for instance) and set it only if it's not already set, otherwise do nothing.
In pseudocode, this should look similar to that:
Code: Select all
/* all this should be done atomically */
check mem location 0x1000
if *(uint32_t 0x1000 *) == 0x1
do nothing
else
/* set to 0x1 */
*(uint32_t 0x1000 *) = 0x1