Results 1 to 1 of 1
Hi.
I'm programming in C++ on Redhawk Linux (a realtime flavor of Redhat). I have a program with two threads--the main thread, and one I create with pthread_create. I want ...
- 01-15-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 2
Does pthread_mutex_init need global pthread_mutexattr_t?
Hi.
I'm programming in C++ on Redhawk Linux (a realtime flavor of Redhat). I have a program with two threads--the main thread, and one I create with pthread_create. I want to share a mutex between these two threads. To facilitate this, I have a global variable of type pthread_mutex_t. I initialize this mutex with a call to pthread_mutex_init. I pass to that function a pthread_mutexattr_t value set to indicate PTHREAD_MUTEX_ERRORCHECK.
My question is this. Though my mutex variable is global (so it can be shared between threads), does the pthread_mutexattr_t that I pass to the pthread_mutex_init function also need to be global? Or can it just be local to the function that calls pthread_mutex_init?
Thanks for any info!
Ken


Reply With Quote