summaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-05-06 20:00:59 -0400
committerRich Felker <dalias@aerifal.cx>2011-05-06 20:00:59 -0400
commitf16a3089be33a75ef8e75b2dd5ec3095996bbb87 (patch)
tree24bf14e183f0e29993b07a9508ce5bd44c4ad2bb /src/internal
parent202911435b56fe007ca62fc6e573fa3ea238d337 (diff)
downloadmusl-f16a3089be33a75ef8e75b2dd5ec3095996bbb87.tar.gz
musl-f16a3089be33a75ef8e75b2dd5ec3095996bbb87.tar.bz2
musl-f16a3089be33a75ef8e75b2dd5ec3095996bbb87.tar.xz
musl-f16a3089be33a75ef8e75b2dd5ec3095996bbb87.zip
completely new barrier implementation, addressing major correctness issues
the previous implementation had at least 2 problems: 1. the case where additional threads reached the barrier before the first wave was finished leaving the barrier was untested and seemed not to be working. 2. threads leaving the barrier continued to access memory within the barrier object after other threads had successfully returned from pthread_barrier_wait. this could lead to memory corruption or crashes if the barrier object had automatic storage in one of the waiting threads and went out of scope before all threads finished returning, or if one thread unmapped the memory in which the barrier object lived. the new implementation avoids both problems by making the barrier state essentially local to the first thread which enters the barrier wait, and forces that thread to be the last to return.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/pthread_impl.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index 304bf98d..049f5dfb 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -68,10 +68,10 @@ struct __timer {
#define _rw_readers __u.__i[1]
#define _rw_waiters __u.__i[2]
#define _rw_owner __u.__i[3]
-#define _b_count __u.__i[0]
-#define _b_limit __u.__i[1]
-#define _b_left __u.__i[2]
-#define _b_waiters __u.__i[3]
+#define _b_inst __u.__p[0]
+#define _b_limit __u.__i[2]
+#define _b_lock __u.__i[3]
+#define _b_waiters __u.__i[4]
#include "pthread_arch.h"