druntime thread_needLock()

Fawzi Mohamed fmohamed at mac.com
Sun Dec 7 02:01:44 PST 2008

On 2008-12-07 09:23:01 +0100, Sean Kelly <sean at invisibleduck.org> said:

> Fawzi Mohamed wrote:
>> On 2008-12-07 03:48:40 +0100, Sean Kelly <sean at invisibleduck.org> said:
>>> Not true.  You would need an acquire barrier in thread_needLock. 
>>> However, on x86 the point is probably moot since loads have acquire 
>>> semantics anyway.
>> You would need a very good processor to reorder speculative loads 
>> before a function call and a branch. As far as I know even alpha did 
>> not do it.
> But if thread_needLock() is inlined...
>> A volatile statement will probably be enough in all cases, but you are 
>> right that to be really correct a load barrier should be done, an even 
>> in a processor where this might matter the cost of it in the fast path 
>> will be basically 0 (so still better than a lock).
> Aye.  I'd do this if there were a common use case that justified it, 
> but I don't see one.

I fully agree with you (see my answer to Robert Fraser)
> Sean

More information about the Digitalmars-d mailing list