[cpp-threads] Somewhat relevant technical report

Peter Dimov pdimov at mmltd.net
Sat Dec 17 22:21:13 GMT 2005


Alexander Terekhov wrote:
> On 12/17/05, Peter Dimov <pdimov at mmltd.net> wrote:
>> Alexander Terekhov wrote:
>>> On 12/17/05, Peter Dimov <pdimov at mmltd.net> wrote:
>>> [...]
>>>> I agree that the lock/unlock pair prevents this transformation.
>>>
>>> Nope. A dummy lock can be removed entirely.
>>
>> It can't unless the compiler can prove that it's not being locked
>> anywhere else.
>
> What do you mean by "anywhere else"? Even if compiler doesn't remove
> it,

I was thinking mainly from compiler point of view, yes; lock+unlock would 
stop the read of v1 being hoisted above it.

> implementation of lock() may check old owner thread id and omit
> hoist-load barrier (e.g. isync on Power) when old owner is none or
> equal to the calling thread.

Interesting, but... doesn't checking the old thread id require a hoist-load? 
You could read "previous previous owner" instead of "previous owner" 
otherwise, if the read is hoisted above the lock acquisiton... 




More information about the cpp-threads mailing list