[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
condition variable implementation question
From: |
Bruno Haible |
Subject: |
condition variable implementation question |
Date: |
Mon, 13 Oct 2008 01:45:34 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Yoann, Ben, or anyone interested in threading,
Is this comment right or wrong?
In glibc's implementation of the wait and timed_wait methods for condition
variables, after returning from the blocking call, first the bookkeeping
in the condition variable is completed, then finally the lock is acquired
again.
In gnulib's gthread-win32.c it is the opposite: first the lock is taken,
then the bookkeeping is completed.
I think both implementations are right. OK to commit these comments?
2008-10-12 Bruno Haible <address@hidden>
* lib/glthread/cond.c (glthread_cond_wait_func,
glthread_cond_timedwait_func): Add comments.
--- lib/glthread/cond.c.orig 2008-10-12 22:05:50.000000000 +0200
+++ lib/glthread/cond.c 2008-10-12 21:30:47.000000000 +0200
@@ -159,7 +159,8 @@
break;
}
- /* Take the lock again. */
+ /* Take the lock again. It does not matter whether this is done
+ before or after the bookkeeping. */
err = glthread_lock_lock (lock);
/* Do the bookkeeping. */
@@ -285,7 +286,8 @@
break;
}
- /* Take the lock again. */
+ /* Take the lock again. It does not matter whether this is done
+ before or after the bookkeeping. */
err = glthread_lock_lock (lock);
/* Do the bookkeeping. */
- condition variable implementation question,
Bruno Haible <=