Practice ยท 2 of 3
Publish with Release, Observe with Acquire
CHALLENGE
Difficulty: advanced+25 XP
ISO C11. Implement the publish pattern: void publish(atomic_int *flag, atomic_int *data, int payload) stores payload into data (relaxed), then stores 1 into flag (release). int observe(const atomic_int *flag, const atomic_int *data) loads flag with acquire; when it sees 1 it must see the payload โ return the data value, or -1 when flag is not yet 1.
Press Submit to check your solution.
Back to lesson: Practice: Atomics and Ordering Drills