Ordering::Release

If Acquire is the starting line of a lock, then Release is the finish line. In fact, the LLVM documentation says:

"Release is similar to Acquire, but with a barrier of the sort necessary to release a lock."

It's may be a little more subtle than lock might suggest, though. Here's what the Rust documentation has to say:

"When coupled with a store, all previous writes become visible to the other threads that perform a load with Acquire ordering on the same value."

Where Acquire stopped loads and stores after itself from migrating upward, Release stops loads and stores prior to itself from migrating downward, with regard to program order. Like Acquire, Release does not stop loads and stores prior to itself from migrating up. A Release store is akin to the finish line of a lock, but one that is porous on the bottom side.

Incidentally, there's an interesting complication here that lock intuition is not helpful with. Question: can two Acquire loads or two Release stores happen simultaneously? The answer is, well, it depends on quite a lot, but it is possible. In the preceding hopper example, the spinning pop_front thread does not block the push_back thread from performing its check of size, either by permanently holding the size until a Release came along to free the pop_front thread, even temporarily, until the while loop can be checked. Remember, the causality model of the language says nothing about the ordering of two Acquire loads or Release stores. It's undefined what happens and is probably going to strongly depend on your hardware. All we do know is that the pop_front thread will not partially see the stores done to memory by push_back; it'll be all-or-none. All of the loads and stores after an Acquire and before a Release come as a unit.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.98.207