On Sat, Nov 09, 2002 at 12:39:43PM +0000, Miles Sabin wrote: >> What do the C standards guarantee if we use 'volatile static'?
> They don't say anything about semantics in multi-threaded/processor > environments. What exactly do they say about 'volatile' anyway? >> Your proposed code can't work as intended (your 'tmp' flag is a local >> copy of 'init', so the second check is redundant). > Hmm ... > > Well, looking at Doug Schmidts code (from the book) this is what he does > too. OTOH, the version here, > > >http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html#explicitMemoryBarriers > > (which is more recent, so probably more reliable) uses volatile > differently and has an extra read before the second check, which would > give us something like this, [...] This version makes a lot more sense. If we want to add memory barrier code, we should do this via an application-defined callback (similar to how we handle locks). -- Bodo Möller <[EMAIL PROTECTED]> PGP http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller/0x36d2c658.html * TU Darmstadt, Theoretische Informatik, Alexanderstr. 10, D-64283 Darmstadt * Tel. +49-6151-16-6628, Fax +49-6151-16-6036 ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]