Static libraries initialization

Ross Johnson Ross.Johnson@homemail.com.au
Sat Apr 26 00:07:00 GMT 2008


Ross Johnson wrote:
>>
>> The overhead of one if()? If the branch prediction sets the if() to 
>> be unlikely, there should be 1 memory access and 1 cmp function 
>> overhead. It shouldn't even disturb the instruction pipeline.
> Yes, it's almost negligible and I use the same method to initialise 
> static POSIX mutexes, cond vars, etc., although this one is slightly 
> worse in that the data isn't necessarily in cache already or local. 
> IIRC, we need to use an Interlocked routine to compare the value, not 
> for atomicity necessarily but so that we get the memory barrier 
> effects right. And I've found that these calls can be relatively slow 
> due to bus locking. I'm also still assuming that every single routine 
> needs this overhead, but that may not be necessary in the end.
I'll retract my interlocked/memory fence comments - they aren't needed 
here. I keep forgetting it's just the first quick check, and the second 
thorough check will only ever be performed once or twice.

Ross



More information about the Pthreads-win32 mailing list