aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/mutex.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-05-24 07:25:43 +0000
committerUlrich Drepper <drepper@redhat.com>2001-05-24 07:25:43 +0000
commit9c4a51972f5de318f3786938949b8320a385fef1 (patch)
tree54cb92794d8a11e75a11114b4acacc2532e75109 /linuxthreads/mutex.c
parent64b7897d6d453e67afe3f9d81c8fc37c26f8d483 (diff)
downloadglibc-9c4a51972f5de318f3786938949b8320a385fef1.tar
glibc-9c4a51972f5de318f3786938949b8320a385fef1.tar.gz
glibc-9c4a51972f5de318f3786938949b8320a385fef1.tar.bz2
glibc-9c4a51972f5de318f3786938949b8320a385fef1.zip
Update.
2001-05-01 Kaz Kylheku <kaz@ashi.footprints.net> Memory barrier overhaul following line by line inspection. * mutex.c (pthread_once): Missing memory barriers added. * pthread.c (__pthread_wait_for_restart_signal, __pthread_timedsuspend_new, __pthread_restart_new): Added memory barriers ``just in case'' and for documentary value. * spinlock.c (__pthread_release): New inline function for releasing spinlock, to complement __pthread_acquire. Includes memory barrier prior to assignment to spinlock, and __asm __volatile dance to prevent reordering or optimization of the spinlock access. * spinlock.c (__pthread_unlock, __pthread_alt_lock, __pthread_alt_timedlock, __pthread_alt_unlock, __pthread_compare_and_swap): Updated to use new __pthread_release instead of updating spinlock directly. * spinlock.c (__pthread_lock, __pthread_unlock, wait_node_alloc, wait_node_free, wait_node_dequeue, __pthread_alt_lock, __pthread_alt_timedlock, __pthread_alt_unlock, __pthread_acquire): Memory barrier overhaul. Lots of missing memory barriers added, a couple needless ones removed. * spinlock.c (__pthread_compare_and_swap): testandset optimization removed, just calls __pthread_acquire, which has the new read barrier in it before its testandset.
Diffstat (limited to 'linuxthreads/mutex.c')
-rw-r--r--linuxthreads/mutex.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/linuxthreads/mutex.c b/linuxthreads/mutex.c
index 3ad27942af..3c97ea7d66 100644
--- a/linuxthreads/mutex.c
+++ b/linuxthreads/mutex.c
@@ -285,7 +285,10 @@ int __pthread_once(pthread_once_t * once_control, void (*init_routine)(void))
int state_changed;
/* Test without locking first for speed */
- if (*once_control == DONE) return 0;
+ if (*once_control == DONE) {
+ READ_MEMORY_BARRIER();
+ return 0;
+ }
/* Lock and test again */
state_changed = 0;
@@ -310,6 +313,7 @@ int __pthread_once(pthread_once_t * once_control, void (*init_routine)(void))
init_routine();
pthread_cleanup_pop(0);
pthread_mutex_lock(&once_masterlock);
+ WRITE_MEMORY_BARRIER();
*once_control = DONE;
state_changed = 1;
}