a POSIX incompliance issue with pthread_mutex_trylock()
"Liu, Bing Wei" <[email protected]> Thu, 30 Jan 2003 09:59:42 +0800
| Newsgroups | gmane.linux.ngpt.user |
|---|---|
| Message-ID | <[email protected]> |
I am working in the Open POSIX Test Suite project at
http://posixtest.sourceforge.net/, whose goal is to perform conformance,
functional, stress, and performance testing of POSIX APIs. When running
tests upon ngpt-2.2.0, I found an incompliance behavior. If a thread calls
pthread_mutex_trylock() on a mutex that it already owns, the function
returns EDEADLK. But according to the standards, only pthread_mutex_lock
should return EDEADLK, while pthread_mutex_trylock should return EBUSY
instead.
I am posting a patch which may address this issue.
--- ngpt-2.2.0-orig/pth_sync.c 2003-01-30 09:38:57.000000000 +0800
+++ ngpt-2.2.0/pth_sync.c 2003-01-30 09:40:41.000000000 +0800
@@ -273,6 +273,8 @@
return 0;
} else {
_pth_release(&(mutex->mx_lock), descr->tid);
+ if(tryonly)
+ return EBUSY;
return EDEADLK;
}
}
@@ -419,6 +421,8 @@
return 0;
} else {
_pth_release(&(mutex->mx_lock), descr->tid);
+ if(tryonly)
+ return EBUSY;
return EDEADLK;
}
}
Bingwei Liu
Software Engineer, Intel Corporation
[email protected]
This email message solely contains my own personal views, and not
necessarily those of my employer