diff options
author | jb <jb@FreeBSD.org> | 1998-11-15 09:58:26 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1998-11-15 09:58:26 +0000 |
commit | 3715314d366a89dbd7df6124d745c95e1bdde448 (patch) | |
tree | 9a0fe180209378fbce78fde57445392dcdc88fc5 /lib/libc_r/uthread/uthread_mutex.c | |
parent | ffd97e5342d926be2f35b764575b61c28801658c (diff) | |
download | FreeBSD-src-3715314d366a89dbd7df6124d745c95e1bdde448.zip FreeBSD-src-3715314d366a89dbd7df6124d745c95e1bdde448.tar.gz |
Close a window between unlocking a spinlock and changing the thread state.
Diffstat (limited to 'lib/libc_r/uthread/uthread_mutex.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_mutex.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c index 4f4aa8a..a7e8dfe 100644 --- a/lib/libc_r/uthread/uthread_mutex.c +++ b/lib/libc_r/uthread/uthread_mutex.c @@ -257,11 +257,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) */ _thread_queue_enq(&(*mutex)->m_queue, _thread_run); - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - - /* Block signals: */ - _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__); + /* Wait for the mutex: */ + _thread_kern_sched_state_unlock( + PS_MUTEX_WAIT, &(*mutex)->lock, + __FILE__, __LINE__); /* Lock the mutex again: */ _SPINLOCK(&(*mutex)->lock); @@ -290,11 +289,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) */ _thread_queue_enq(&(*mutex)->m_queue, _thread_run); - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - - /* Block signals: */ - _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__); + /* Wait for the mutex: */ + _thread_kern_sched_state_unlock( + PS_MUTEX_WAIT, &(*mutex)->lock, + __FILE__, __LINE__); /* Lock the mutex again: */ _SPINLOCK(&(*mutex)->lock); |