Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!news.ecp.fr!news-rocq.inria.fr!not-for-mail From: Jens Gustedt Newsgroups: comp.std.c,comp.lang.c Subject: Re: The threading specs in the standard: a new catastrophe Date: Sun, 10 Jul 2011 14:47:20 +0200 Organization: INRIA - CR Paris-Rocquencourt Lines: 26 Message-ID: <4E199F58.70606@loria.fr> References: <97m59uF1nsU1@mid.individual.net> <97mluqFbcvU6@mid.individual.net> <4E16D89D.20302@loria.fr> NNTP-Posting-Host: lor082r.vpn.inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: news-rocq.inria.fr 1310302046 15454 128.93.180.82 (10 Jul 2011 12:47:26 GMT) X-Complaints-To: newsmaster@inria.fr To: Marcin Grzegorczyk User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: X-Enigmail-Version: 1.1.2 Xref: x330-a1.tempe.blueboxinc.net comp.std.c:707 comp.lang.c:8067 Am 10.07.2011 00:02, schrieb Marcin Grzegorczyk: > No such thing is implied in the draft Standard. The reason is that some > existing mutex implementations do not provide static initialization; > most notably, under Win32, neither mutex objects nor critical section > objects do (barring some tricks that may break if Microsoft decides to > change the underlying implementation, again). Hm, I first thought that a once_flag could be used to launch an initializer function for such statically objects. As such this is not possible, since the call_once interface doesn't allow the function parameter to receive an argument. But an implementation would have to provide call_once & Co. So you'd have to have - some sort of atomic read of the once_flag - the potential to delay all but one threads that stumble into this simultaneaously - the potential to have the very first thread call an initialization function These ingredients could be used equally well to call an mtx_init and cnd_init on statically initialized objects, I think. Performance cost of such things should be minor. Jens