This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static libraries initialization


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]