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