Am Freitag den, 30. August 2002, um 11:33, schrieb Dr. Uwe Girlich:
>
> On Fri, Aug 30, 2002 at 09:56:20AM +0200, Dr. Uwe Girlich wrote:
>> There is an error in the POSIX semaphore implementation in NGPT:
> ...
>> The attached patch file corrects this strange behaviour.
> This correction corrects the behaviour of process shared semaphores.
> Process local semaphores are still wrong. I'll look into it.
Does your code uses sem_trywait()?
In that function the mutex is not released in every code path.
Another question: Is that double locking required? When all functions
accessing the semaphore use __sem_waiting->__lock, why is
__sem_waiting->__sem_lock needed? Just for destroying it safely?
--- semaphore.c.orig Fri Aug 30 15:04:23 2002
+++ semaphore.c Fri Aug 30 15:06:02 2002
@@ -100,9 +100,11 @@
retval = pthread_mutex_trylock(&sem->__sem_waiting->__lock);
if (retval == 0) {
- if (sem->__sem_value == 0)
- retval = -1;
- else {
+ if (sem->__sem_value == 0){
+ return_errno(-1, EAGAIN);
+ pthread_mutex_unlock(&sem->__sem_waiting->__lock);
+ return -1;
+ } else {
pth_acquire_lock(&sem->__sem_waiting->__sem_lock);
sem->__sem_value--;
pth_release_lock(&sem->__sem_waiting->__sem_lock);
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.