Actions
| Post | |
| Subscribe | |
| Unsubscribe |
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] Initialization of local static mutex
- To: c++-pthreads@xxxxxxxxxxxxxxxx
- Subject: Re: [c++-pthreads] Initialization of local static mutex
- From: Roland Schwarz <roland.schwarz@xxxxxxxxx>
- Date: Sun, 08 Oct 2006 17:04:01 +0200
Your answer does not yet silence my doubts: George Shimanovich wrote: > There will be no race condition between two static initializations and > any static and non-static initialization: > 1) The zero-initialization of static mutex is performed before its > initialization with constant-expression PTHREAD_MUTEX_INITIALIZER Ok, this is said by the first sentence of 6.7/4. > 2) The initialization with that constant-expression occurs before any > non-static initialization in foo Ok, this is covered by the next sentence > 3) Compiler makes sure that each static initialization is done only once The 3) still puzzles me. If the compiler makes this sure, he has to remember this fact somewhere, i.e. in a (global, hidden) state variable. Access to this variable poses a race condition, and since the PTHREAD_MUTEX_INITIALIZER might not be copied in an atomic manner, the assignment itself is not thread safe. Roland
- Prev by Date: Initialization of local static mutex
- Next by Date: Re: [c++-pthreads] Initialization of local static mutex
- Previous by thread: Re: [c++-pthreads] Initialization of local static mutex
- Next by thread: Does the cancelation exception have a name?
- Index(es):