diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c index 7e1bace02cf3..311cf1e9b11b 100644 --- a/lib/libthr/thread/thr_cancel.c +++ b/lib/libthr/thread/thr_cancel.c @@ -80,12 +80,12 @@ retry: * Disconnect the thread from the joinee: */ if ((joined = pthread->join_status.thread) != NULL) { - if (_spintrylock(&joined->lock) == EBUSY) { + if (THR_TRYLOCK(&joined->lock) == EBUSY) { _thread_critical_exit(pthread); goto retry; } pthread->join_status.thread->joiner = NULL; - _spinunlock(&joined->lock); + THR_UNLOCK(&joined->lock); joined = pthread->join_status.thread = NULL; } pthread->cancelflags |= PTHREAD_CANCELLING; diff --git a/lib/libthr/thread/thr_detach.c b/lib/libthr/thread/thr_detach.c index 23e985f72f4b..6161e869bf3f 100644 --- a/lib/libthr/thread/thr_detach.c +++ b/lib/libthr/thread/thr_detach.c @@ -44,10 +44,10 @@ _pthread_detach(pthread_t pthread) if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) return (EINVAL); - _SPINLOCK(&pthread->lock); + THR_LOCK(&pthread->lock); if (pthread->attr.flags & PTHREAD_DETACHED) { - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); return (EINVAL); } @@ -73,7 +73,7 @@ _pthread_detach(pthread_t pthread) _thread_critical_exit(joiner); } - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); return (0); } diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c index bea78742e739..441e730aaec3 100644 --- a/lib/libthr/thread/thr_exit.c +++ b/lib/libthr/thread/thr_exit.c @@ -146,7 +146,7 @@ retry: /* Check if there is a thread joining this one: */ if (curthread->joiner != NULL) { pthread = curthread->joiner; - _SPINLOCK(&pthread->lock); + THR_LOCK(&pthread->lock); curthread->joiner = NULL; /* Make the joining thread runnable: */ @@ -156,7 +156,7 @@ retry: pthread->join_status.ret = curthread->ret; pthread->join_status.error = 0; pthread->join_status.thread = NULL; - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); /* Make this thread collectable by the garbage collector. */ PTHREAD_ASSERT(((curthread->attr.flags & PTHREAD_DETACHED) == diff --git a/lib/libthr/thread/thr_gc.c b/lib/libthr/thread/thr_gc.c index e2aa75331893..09489967635c 100644 --- a/lib/libthr/thread/thr_gc.c +++ b/lib/libthr/thread/thr_gc.c @@ -106,7 +106,7 @@ _thread_gc(pthread_addr_t arg) if (pthread == _thread_initial) continue; - _SPINLOCK(&pthread->lock); + THR_LOCK(&pthread->lock); /* * Check if the stack was not specified by @@ -128,7 +128,7 @@ _thread_gc(pthread_addr_t arg) * it on the dead thread list. */ if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) { - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); continue; } @@ -141,7 +141,7 @@ _thread_gc(pthread_addr_t arg) */ pthread_cln = pthread; - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); /* * Retire the architecture specific id so it may be diff --git a/lib/libthr/thread/thr_join.c b/lib/libthr/thread/thr_join.c index 2a5433aeb80e..8b579781ef1b 100644 --- a/lib/libthr/thread/thr_join.c +++ b/lib/libthr/thread/thr_join.c @@ -33,6 +33,7 @@ */ #include #include +#include #include "thr_private.h" __weak_reference(_pthread_join, pthread_join); @@ -69,7 +70,7 @@ _pthread_join(pthread_t pthread, void **thread_return) THREAD_LIST_LOCK; TAILQ_FOREACH(thread, &_thread_list, tle) if (thread == pthread) { - _SPINLOCK(&pthread->lock); + THR_LOCK(&pthread->lock); break; } @@ -79,7 +80,7 @@ _pthread_join(pthread_t pthread, void **thread_return) */ TAILQ_FOREACH(thread, &_dead_list, dle) if (thread == pthread) { - _SPINLOCK(&pthread->lock); + THR_LOCK(&pthread->lock); break; } @@ -87,7 +88,7 @@ _pthread_join(pthread_t pthread, void **thread_return) if (thread == NULL || ((pthread->attr.flags & PTHREAD_DETACHED) != 0)) { if (thread != NULL) - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); THREAD_LIST_UNLOCK; DEAD_LIST_UNLOCK; ret = ESRCH; @@ -97,7 +98,7 @@ _pthread_join(pthread_t pthread, void **thread_return) if (pthread->joiner != NULL) { /* Multiple joiners are not supported. */ /* XXXTHR - support multiple joiners. */ - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); THREAD_LIST_UNLOCK; DEAD_LIST_UNLOCK; ret = ENOTSUP; @@ -109,7 +110,7 @@ _pthread_join(pthread_t pthread, void **thread_return) if (pthread->state != PS_DEAD) { /* Set the running thread to be the joiner: */ pthread->joiner = curthread; - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); _thread_critical_enter(curthread); /* Keep track of which thread we're joining to: */ @@ -159,7 +160,7 @@ _pthread_join(pthread_t pthread, void **thread_return) /* Make the thread collectable by the garbage collector. */ pthread->attr.flags |= PTHREAD_DETACHED; - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); THREAD_LIST_UNLOCK; if (pthread_cond_signal(&_gc_cond) != 0) PANIC("Cannot signal gc cond"); diff --git a/lib/libthr/thread/thr_kern.c b/lib/libthr/thread/thr_kern.c index 4a60bfe21f46..481cc835ce0f 100644 --- a/lib/libthr/thread/thr_kern.c +++ b/lib/libthr/thread/thr_kern.c @@ -56,13 +56,13 @@ void _thread_critical_enter(pthread_t pthread) { _thread_sigblock(); - _SPINLOCK(&pthread->lock); + THR_LOCK(&pthread->lock); } void _thread_critical_exit(pthread_t pthread) { - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); _thread_sigunblock(); } diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 40921ec6e952..067f0f0288c8 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -1263,9 +1263,9 @@ _mutex_lock_backout(pthread_t pthread) /* _thread_kern_sig_defer();*/ /* XXX - Necessary to obey lock order */ - _SPINLOCK(&pthread->lock); + THR_LOCK(&pthread->lock); mutex = pthread->data.mutex; - _SPINUNLOCK(&pthread->lock); + THR_UNLOCK(&pthread->lock); _SPINLOCK(&mutex->lock);