Reputation: 17
Is function pthread_mutexattr_settype
different then pthread_mutexattr_setkind_np
?
I got random output, and i'm not sure...
Im trying to see whats happend if i type Normal, Error check and Recursive type of mutex...
switch(atoi(argv[1])){
case 1:
puts("ERROR CHECK");
pthread_mutexattr_settype(&m_attr, PTHREAD_MUTEX_ERRORCHECK);
break;
case 2:
puts("RECURSIVE");
pthread_mutexattr_settype(&m_attr, PTHREAD_MUTEX_RECURSIVE);
break;
default:
puts("NORMAL");
pthread_mutexattr_settype(&m_attr, PTHREAD_MUTEX_NORMAL);
break;
}
puts("Before 1 lock");
pthread_mutex_lock(&data->mutex);
test_errno("1 lock");
puts(" After 1 lock");
puts("Before 2 lock");
pthread_mutex_lock(&data->mutex);
test_errno("2 lock");
puts(" After 2 lock");
puts("Before 1 unlock");
pthread_mutex_unlock(&data->mutex);
test_errno("1 unlock");
puts(" After 1 ulock");
puts("Before 2 unlock");
pthread_mutex_unlock(&data->mutex);
test_errno("2 unlock");
puts(" After 2 ulock");
Upvotes: 0
Views: 140
Reputation: 2002
If you look at the sourcecode (ftp://sourceware.org/pub/pthreads-win32/sources/pthreads-w32-2-9-1-release/pthread_mutexattr_setkind_np.c) you will find the following:
int
pthread_mutexattr_setkind_np (pthread_mutexattr_t * attr, int kind)
{
return pthread_mutexattr_settype (attr, kind);
}
The two methods also also have the exact same signature except for their names, so you can rely on their being aliases of each other. The manual page https://sourceware.org/pthreads-win32/manual/pthread_mutexattr_init.html also states that pthread_mutexattr_setkind_np
is an alias for pthread_mutexattr_settype
.
Upvotes: 2