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: Jean-Marc Bourguet <jm.bourguet@xxxxxxxxx>
- Date: Tue, 10 Oct 2006 08:05:16 +0200
Mark Mitchell wrote:
Roland Schwarz wrote:
Now that you have brought up this issue I am curious which "other issues" you are refering to.void f() { static int i = g(); }Here, you cannot do the initialization statically; it must be done the first time that f() is called. So, the key question is whether the initialization is thread-safe. Does the programmer have to change that initialization to be thread-safe, using locks in f()? Or does the compiler take care of it?
I fail to see how the programmer can make the initialization thread-safe if the compiler doesn't take care of it? Lack of memory barriers could make the bool indicating that the initialization is done visible, but not the written value.
-- Jean-Marc
- Follow-Ups:
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Re: [c++-pthreads] Initialization of local static mutex
- References:
- Initialization of local static mutex
- From: Roland Schwarz
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Re: [c++-pthreads] Initialization of local static mutex
- From: Roland Schwarz
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Re: [c++-pthreads] Initialization of local static mutex
- From: Roland Schwarz
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Re: [c++-pthreads] Initialization of local static mutex
- From: Roland Schwarz
- Re: [c++-pthreads] Initialization of local static mutex
- From: Mark Mitchell
- Initialization of local static mutex
- Prev by Date: Re: [c++-pthreads] 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: Re: [c++-pthreads] Initialization of local static mutex
- Index(es):