About spinlock implementation

mogu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 1 01:30:25 PDT 2016


On Thursday, 1 September 2016 at 07:46:04 UTC, qznc wrote:
>
> I'm not sure I understand rel [0], but raw is too weak. Raw 
> means no sequencing barrier, so
>
>   local_var = protected_value;
>   spinlock.unlock();
>
> could be transformed (by compiler or CPU) to
>
>   spinlock.unlock();
>   local_var = protected_value;
>
> This effectively makes the access to the protected value 
> unprotected and nullifies the effect of the spinlock.
>
> I find the documentation on MemoryOrder lacking about the 
> semantics of rel. :(
>
> [0] https://dlang.org/library/core/atomic/memory_order.html

Thanks very much. I finally got it. :)


More information about the Digitalmars-d-learn mailing list