diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-05-24 07:25:43 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-05-24 07:25:43 +0000 |
commit | 9c4a51972f5de318f3786938949b8320a385fef1 (patch) | |
tree | 54cb92794d8a11e75a11114b4acacc2532e75109 /linuxthreads/pthread.c | |
parent | 64b7897d6d453e67afe3f9d81c8fc37c26f8d483 (diff) | |
download | glibc-9c4a51972f5de318f3786938949b8320a385fef1.tar.gz glibc-9c4a51972f5de318f3786938949b8320a385fef1.tar.xz 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/pthread.c')
-rw-r--r-- | linuxthreads/pthread.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c index 4340a7cc65..e48753b069 100644 --- a/linuxthreads/pthread.c +++ b/linuxthreads/pthread.c @@ -941,6 +941,8 @@ void __pthread_wait_for_restart_signal(pthread_descr self) do { sigsuspend(&mask); /* Wait for signal */ } while (THREAD_GETMEM(self, p_signal) !=__pthread_sig_restart); + + READ_MEMORY_BARRIER(); /* See comment in __pthread_restart_new */ } #if !__ASSUME_REALTIME_SIGNALS @@ -1043,7 +1045,12 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime) void __pthread_restart_new(pthread_descr th) { - kill(th->p_pid, __pthread_sig_restart); + /* The barrier is proabably not needed, in which case it still documents + our assumptions. The intent is to commit previous writes to shared + memory so the woken thread will have a consistent view. Complementary + read barriers are present to the suspend functions. */ + WRITE_MEMORY_BARRIER(); + kill(th->p_pid, __pthread_sig_restart); } /* There is no __pthread_suspend_new because it would just @@ -1101,6 +1108,7 @@ __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime) the caller; the thread is still eligible for a restart wakeup so there is a race. */ + READ_MEMORY_BARRIER(); /* See comment in __pthread_restart_new */ return was_signalled; } |