I am wondering whether the Florida State University implementation of the pthread standard is, by any chance, able to handle the recursive mutexes. Unfortunately the documentation about the FSU implementation is rather poor, and it does not mention of the possibility or not to declare a mutex as recursive.
Trying to declare a mutex as follows:
pthread_mutex_attr mutex_attr;
pthread_mutexattr_init (&mutex_attr);
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mutex, NULL);
and compiling using the FSU pthreads library, I got this list of errors:
test.c:25: error: `pthread_mutex_attr' undeclared (first use in this function)
test.c:25: error: (Each undeclared identifier is reported only once
test.c:25: error: for each function it appears in.)
test.c:25: error: parse error before "mutex_attr"
test.c:27: error: `mutex_attr' undeclared (first use in this function)
test.c:28: error: `PTHREAD_MUTEX_RECURSIVE' undeclared (first use in this function)
Trying to compile the same code with the (non-FSU) pthread implementation on my machine, it works.
To avoid trivialities, I tell you in advance that, by default, the POSIX mutexes are not recursive.
Should I conclude that there is no way to make use of recursive mutexes with the FSU implementation, or there is another way to achieve these (i.e. another way to declare a mutex as recursive)?
No, the FSU pthreads implementation does not support recursive mutexes. In fact, the latest release has no notion of mutex types. In addition to lacking the PTHREAD_MUTEX_*
mutex type names, it also omits the pthread_mutexattr_settype()
and pthread_mutexattr_gettype()
functions used to manipulate the mutex type.