Re: [PATCH] compat: Allow static initializer for pthreads on Windows
- From
Jacob Keller <jacob.keller@gmail.com>
- Date
- Oct 28, 2016, 18:49 UTC
- Message-ID
- <CA+P7+xoNSrhaQ50GZ4RzLregznw+0yf2=ttNuYf1VUw+YabdFQ@mail.gmail.com>
- In-Reply-To
- <B5FD05E58E36480894F1BDBBC9589EE1@PhilipOakley>
On Fri, Oct 28, 2016 at 6:01 AM, Philip Oakley <philipoakley@iee.org> wrote:
Show 19 quoted lines
> From: "Johannes Sixt" <j6t@kdbg.org> >> >> >> One point is that the DCLP idiom must be implemented correctly. There are >> solutions, of course, and when the initialization is over, we have a >> miniscule overhead at each pthread_mutex_lock call. >> > > I had to look up DCLP ( = Double Checked Locking Patterns), and found a good > write up on the issues.. > > http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf "C++ and the > Perils of Double-Checked Locking", which include 'C' issues, and > multi-thread, multi-processor issues. Not an easy issue when fighting > optimisers.. > > -- > > Philip
Yep, this is why we have memory barriers. Ofcourse languages like C don't really allow you to express them in the language and we restore to various platform specific methods.
Thanks, Jake