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/libpthread/thread/thr_cond.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/libpthread/thread/thr_cond.c')
-rw-r--r-- | lib/libpthread/thread/thr_cond.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c index e9b687d..a085ea6 100644 --- a/lib/libpthread/thread/thr_cond.c +++ b/lib/libpthread/thread/thr_cond.c @@ -165,12 +165,9 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); } else { - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - /* Schedule the next thread: */ - _thread_kern_sched_state(PS_COND_WAIT, - __FILE__, __LINE__); + _thread_kern_sched_state_unlock(PS_COND_WAIT, + &(*cond)->lock, __FILE__, __LINE__); /* Lock the mutex: */ rval = pthread_mutex_lock(mutex); @@ -241,12 +238,9 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); } else { - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - /* Schedule the next thread: */ - _thread_kern_sched_state(PS_COND_WAIT, - __FILE__, __LINE__); + _thread_kern_sched_state_unlock(PS_COND_WAIT, + &(*cond)->lock, __FILE__, __LINE__); /* Lock the mutex: */ if ((rval = pthread_mutex_lock(mutex)) != 0) { |