Go Memory Model Checkpoint

Happens-before, synchronization, and atomic publication.


Get every question correct to pass this checkpoint. You can review feedback, revise your answers, and submit again.

1. A goroutine sets x=42 and closes done. Another receives from the now-closed, unbuffered done channel and then reads x. There are no other writes. What can it rely on?

Select one answer.

2. A buffered channel already contains a token. A writer later changes shared state and closes it. A reader receives the old token and immediately reads state. What assumption is unsafe?

Select one answer.

3. A fully initialized struct containing a map is published with atomic.Pointer. The writer then mutates the same map while readers access it. Is pointer publication enough?

Select one answer.

4. For a mutex-protected value, the visibility edge pairs a prior Unlock with a later successful operation named what?
5. A cell starts at5. Two concurrent swaps install7 and9; both return5. What does this reveal? Select one answer.

Select one answer.

6. A cell starts at2. Swaps install6 and10; final value is6. What predecessor did the swap-to6 return? Enter one integer.
Join Discord