mutex_islocked_np -> mutex_isowned_np

This commit is contained in:
Dag-Erling Smørgrav 2008-02-06 19:41:05 +00:00
parent 1cbdac2668
commit ecd14de7d7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176050
2 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# $FreeBSD$
PROG= mutex_islocked_np
PROG= mutex_isowned_np
NO_MAN=
LDADD= -lpthread

View File

@ -37,8 +37,8 @@ thread(void *arg)
{
pthread_mutex_t *mtx = arg;
if (pthread_mutex_islocked_np(mtx) != 0) {
printf("pthread_mutex_islocked_np() returned non-zero\n"
if (pthread_mutex_isowned_np(mtx) != 0) {
printf("pthread_mutex_isowned_np() returned non-zero\n"
"for a mutex held by another thread\n");
exit(1);
}
@ -52,22 +52,22 @@ main(int argc, char *argv[])
pthread_mutex_t mtx;
pthread_mutex_init(&mtx, NULL);
if (pthread_mutex_islocked_np(&mtx) != 0) {
printf("pthread_mutex_islocked_np() returned non-zero\n"
if (pthread_mutex_isowned_np(&mtx) != 0) {
printf("pthread_mutex_isowned_np() returned non-zero\n"
"for a mutex that is not held\n");
exit(1);
}
pthread_mutex_lock(&mtx);
if (pthread_mutex_islocked_np(&mtx) == 0) {
printf("pthread_mutex_islocked_np() returned zero\n"
if (pthread_mutex_isowned_np(&mtx) == 0) {
printf("pthread_mutex_isowned_np() returned zero\n"
"for a mutex we hold ourselves\n");
exit(1);
}
pthread_create(&thr, NULL, thread, &mtx);
pthread_join(thr, NULL);
pthread_mutex_unlock(&mtx);
if (pthread_mutex_islocked_np(&mtx) != 0) {
printf("pthread_mutex_islocked_np() returned non-zero\n"
if (pthread_mutex_isowned_np(&mtx) != 0) {
printf("pthread_mutex_isowned_np() returned non-zero\n"
"for a mutex that is not held\n");
exit(1);
}