Well, consider what a pthread_mutex actually is. It looks kind of like this:
struct pthread_mutex_t
{
volatile sig_atomic_t spinlock;
int lock_count;
int wait_count;
...
Type: Posts; User: brewbuck
Well, consider what a pthread_mutex actually is. It looks kind of like this:
struct pthread_mutex_t
{
volatile sig_atomic_t spinlock;
int lock_count;
int wait_count;
...
On Linux at least, pthread mutexes can be shared between processes. You have to initialize the mutex within a shared memory segment (something you already have), and set the attributes with:
...
Futexes are used internally by the C library to implement certain kinds of wait states. They are a Linux-specific feature which are meant to be used as a building block for more friendly...
Well, strictly a spinlock is perfectly fine to protect a shared resource, it just chows down on CPU while it does so.