-
pthread_mutex
Do I have to declare a pthread_mutex as an extern so that I may use it in a different program?
I want to control one program by playing with the mutex in another program.
-
Registered User
First your implementation has to support the _POSIX_THREAD_PROCESS_SHARED option.
Then you have to create a pthread_mutexattr_t with the PTHREAD_PROCESS_SHARED attribute.
Then you use some shared memory mechanism to host the actual pthread_mutex_t.
More info with an implemenation here: http://www.opengroup.org/onlinepubs/...r_destroy.html
gg
-
I'm using a fast mutex implementation.
I think I'm running into some race condition - since the processes are running at different rates.
-
Registered User
Are you talking about futex's? Because those are tricky...http://people.redhat.com/drepper/futex.pdf
Another alternative is a Sys-V or Posix semaphore.
gg
-
by fast mutex I was referring to the default instantiation of a mutex using P_THREAD_INSTAN.... somthing or the other.
futexes sound cool, I'll have to dig into that.
What do you mean by Sys-V?
-
Registered User
Ah - ok. Futexes are probably a little more "low-level" than what you need.
To use a pthread_mutex_t across processes, you'll need to follow the steps in my first posting. But it's probably easier to just use a semaphore.
SYSV is short-hand for, and most commonly refers to "Unix System 5, Release 4". Another common acronym is "SVR4". http://en.wikipedia.org/wiki/SysV
Semaphores in the SVR4 specification come from <sys/sem.h> and include the functions semctl(), semget(), and semop().
The Single Unix Specification, aka POSIX, has their own semaphore api from <semaphore.h> and include the functions sem_init(), sem_post(), sem_wait(), sem_destroy(), etc...
gg
Popular pages
Recent additions