Re:A static_cast is not always just a pointer adjustment
by the8472 on Saturday April 02, 2016 @07:44AM
(#11411179)
Garbage collectors (and various other parts of the JVM) use similar tricks to coordinate threads without using memory barriers. The compiler just inserts TEST instructions to some fixed memory address in strategic places in the code.
When the garbage collector needs to run it protects the page and waits until all threads have segfaulted and transferred control to the collector.
When the garbage collector needs to run it protects the page and waits until all threads have segfaulted and transferred control to the collector.