#volatile #membar #dragons #openjdk #mesi
#jmm #store #load #omg #internals
#cachecoherency
#jugru
void executedOnCpu0() { value = 10; finished = true; }
void executedOnCpu1() { while(!finished); assert value == 10; }
finished: Exclusive value: Invalid
finished: Invalid value: Exclusive
while(!finished); ← read(finished)
value = 10; - store_buffer(value) ← invalidate(value)
finished = true;
- finished: Modified
→ read(finished)
← read_response(finished, true)
- finished: Shared
→ read_response(finished, true) - finished: Shared (true)
assert value == 10;
Assertion fails
→ invalidate(value) - value: Invalid ← invalidate_ack(value)
void executedOnCpu0() { value = 10; finished = true; }
void executedOnCpu1() { while(!finished); assert value == 10; }
finished: Exclusive value: Shared
finished: Invalid value: Shared
while(!finished); ← read(finished)
value = 10; - store_buffer(value) ← invalidate(value)
finished = true; - finished: Modified
→ invalidate(value) ← invalidate_ack(value) - invalidate_queue(value)
→ read(finished) ← read_response(finished, true) - finished: Shared
→ read_response(finished, true) - finished: Shared (true)
assert value == 10;
Assertion fails
- value: Invalid
void executedOnCpu0() { value = 10; Magic.storeMemoryBarrier(); finished = true; }
void executedOnCpu1() { while(!finished); Magic.loadMemoryBarrier(); assert value == 10; }
finished: Exclusive value: Shared
finished: Invalid value: Shared
while(!finished); ← read(finished)
value = 10;
- store_buffer(value)
← invalidate(value)
Magic.storeMemoryBarrier();
→ invalidate(value) ← invalidate_ack(value) - invalidate_queue(value)
→ invalidate_ack(value) - writeback(value, 10) - value: Exclusive finished = true; - finished: Modified → read(finished) ← read_response(finished, true) - finished: Shared
→ read_response(finished, true) - finished: Shared (true) Magic.loadMemoryBarrier(); - value: Invalid assert value == 10; ← read(value)
→ read(value) ← read_response(value, 10) - value: Shared
→ read_response(value, 10) - value: Shared (10)
Assertion passes