On Sat, 09 Apr 2011 11:55:02 -0500, Hal Murray wrote:

> Is there any way to test to see if a mutex has been initialized?

One way is to call pthread_mutex_init and check for an EBUSY error return.
See the pthread_mutex_init man page for details.

One could also keep track of initialization status (and which process
initialized) in a variable in shared memory.  Either ignore locking
for setting that variable or try to deal with the chicken-or-egg issue.

I still advise using a semaphore in preference to a mutex, or
better still, avoid shared access entirely.

_______________________________________________
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions

Reply via email to