Re: Need for mutexes when reading global variables
- From: Philip Guenther <guenther@xxxxxxxxx>
- Date: Mon, 22 Sep 2008 20:07:54 -0700 (PDT)
On Sep 22, 7:29 pm, "lancer6...@xxxxxxxxx" <lancer6...@xxxxxxxxx>
wrote:
Is there a need to put a mutex around the reading of a global variable
that is initialized before any threads are created and remains
unchanged for the duration of the program, even though there is no
writes to it?
No mutex is needed for what you describe. pthread_create() is
required to synchronize memory, so any changes to global variables
made before calling it are guaranteed to be visible to the new thread.
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_10
Philip Guenther
.
- Follow-Ups:
- References:
- Need for mutexes when reading global variables
- From: lancer6238@xxxxxxxxx
- Need for mutexes when reading global variables
- Prev by Date: Need for mutexes when reading global variables
- Next by Date: Re: Need for mutexes when reading global variables
- Previous by thread: Need for mutexes when reading global variables
- Next by thread: Re: Need for mutexes when reading global variables
- Index(es):
Relevant Pages
|