thanks in my requirement it is guarenteed that no thread will ever write to it. example is program configs, which are loaded by reading a file perhaps by main thread. other threads won't modify them but read
--- In [email protected], "Paul Herring" <[EMAIL PROTECTED]> wrote: > > On Feb 11, 2008 5:44 AM, Indika Bandara Udagedara > <[EMAIL PROTECTED]> wrote: > > Hi, > > Is it required that variables which are ONLY READ by multiple threads > > needs to be protected by (mutex) locks? > > i.e. it is absolutely guarenteed that they will NEVER try to write to > > them. So is there any possibility of corruption? > > If you have a concurrent thread that may change that value, then yes, > you need some form of mutex. > > The mutex may allow other threads to read the variable concurrently, > but must exclude any thread that may write to the variable to prevent > other threads reading or writing that variable while the change is > taking place. > > Compare down_read() and down_write() for semaphores. > > -- > PJH > > http://shabbleland.myminicity.com/tra >
