Change all instances of THR_LOCK/UNLOCK, etc to UMTX_*.
It is a more acurate description of the locks they operate on.
This commit is contained in:
parent
9644071977
commit
659045ffbf
@ -80,13 +80,13 @@ retry:
|
||||
* Disconnect the thread from the joinee:
|
||||
*/
|
||||
if ((joined = pthread->join_status.thread) != NULL) {
|
||||
THR_TRYLOCK(&joined->lock, ret);
|
||||
UMTX_TRYLOCK(&joined->lock, ret);
|
||||
if (ret == EBUSY) {
|
||||
_thread_critical_exit(pthread);
|
||||
goto retry;
|
||||
}
|
||||
pthread->join_status.thread->joiner = NULL;
|
||||
THR_UNLOCK(&joined->lock);
|
||||
UMTX_UNLOCK(&joined->lock);
|
||||
joined = pthread->join_status.thread = NULL;
|
||||
}
|
||||
pthread->cancelflags |= PTHREAD_CANCELLING;
|
||||
|
@ -44,10 +44,10 @@ _pthread_detach(pthread_t pthread)
|
||||
if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
|
||||
return (EINVAL);
|
||||
|
||||
THR_LOCK(&pthread->lock);
|
||||
UMTX_LOCK(&pthread->lock);
|
||||
|
||||
if (pthread->attr.flags & PTHREAD_DETACHED) {
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ _pthread_detach(pthread_t pthread)
|
||||
_thread_critical_exit(joiner);
|
||||
}
|
||||
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ retry:
|
||||
/* Check if there is a thread joining this one: */
|
||||
if (curthread->joiner != NULL) {
|
||||
pthread = curthread->joiner;
|
||||
THR_LOCK(&pthread->lock);
|
||||
UMTX_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;
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
|
||||
/* Make this thread collectable by the garbage collector. */
|
||||
PTHREAD_ASSERT(((curthread->attr.flags & PTHREAD_DETACHED) ==
|
||||
|
@ -106,7 +106,7 @@ _thread_gc(pthread_addr_t arg)
|
||||
if (pthread == _thread_initial)
|
||||
continue;
|
||||
|
||||
THR_LOCK(&pthread->lock);
|
||||
UMTX_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) {
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ _thread_gc(pthread_addr_t arg)
|
||||
*/
|
||||
pthread_cln = pthread;
|
||||
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
|
||||
/*
|
||||
* Retire the architecture specific id so it may be
|
||||
|
@ -70,7 +70,7 @@ _pthread_join(pthread_t pthread, void **thread_return)
|
||||
THREAD_LIST_LOCK;
|
||||
TAILQ_FOREACH(thread, &_thread_list, tle)
|
||||
if (thread == pthread) {
|
||||
THR_LOCK(&pthread->lock);
|
||||
UMTX_LOCK(&pthread->lock);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ _pthread_join(pthread_t pthread, void **thread_return)
|
||||
*/
|
||||
TAILQ_FOREACH(thread, &_dead_list, dle)
|
||||
if (thread == pthread) {
|
||||
THR_LOCK(&pthread->lock);
|
||||
UMTX_LOCK(&pthread->lock);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ _pthread_join(pthread_t pthread, void **thread_return)
|
||||
if (thread == NULL ||
|
||||
((pthread->attr.flags & PTHREAD_DETACHED) != 0)) {
|
||||
if (thread != NULL)
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
THREAD_LIST_UNLOCK;
|
||||
DEAD_LIST_UNLOCK;
|
||||
ret = ESRCH;
|
||||
@ -98,7 +98,7 @@ _pthread_join(pthread_t pthread, void **thread_return)
|
||||
if (pthread->joiner != NULL) {
|
||||
/* Multiple joiners are not supported. */
|
||||
/* XXXTHR - support multiple joiners. */
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
THREAD_LIST_UNLOCK;
|
||||
DEAD_LIST_UNLOCK;
|
||||
ret = ENOTSUP;
|
||||
@ -110,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;
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
_thread_critical_enter(curthread);
|
||||
|
||||
/* Keep track of which thread we're joining to: */
|
||||
@ -162,7 +162,7 @@ _pthread_join(pthread_t pthread, void **thread_return)
|
||||
|
||||
/* Make the thread collectable by the garbage collector. */
|
||||
pthread->attr.flags |= PTHREAD_DETACHED;
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
THREAD_LIST_UNLOCK;
|
||||
if (pthread_cond_signal(&_gc_cond) != 0)
|
||||
PANIC("Cannot signal gc cond");
|
||||
|
@ -56,13 +56,13 @@ void
|
||||
_thread_critical_enter(pthread_t pthread)
|
||||
{
|
||||
_thread_sigblock();
|
||||
THR_LOCK(&pthread->lock);
|
||||
UMTX_LOCK(&pthread->lock);
|
||||
}
|
||||
|
||||
void
|
||||
_thread_critical_exit(pthread_t pthread)
|
||||
{
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
_thread_sigunblock();
|
||||
}
|
||||
|
||||
|
@ -1291,9 +1291,9 @@ _mutex_lock_backout(pthread_t pthread)
|
||||
/* _thread_kern_sig_defer();*/
|
||||
|
||||
/* XXX - Necessary to obey lock order */
|
||||
THR_LOCK(&pthread->lock);
|
||||
UMTX_LOCK(&pthread->lock);
|
||||
mutex = pthread->data.mutex;
|
||||
THR_UNLOCK(&pthread->lock);
|
||||
UMTX_UNLOCK(&pthread->lock);
|
||||
|
||||
_SPINLOCK(&mutex->lock);
|
||||
|
||||
|
@ -83,20 +83,20 @@
|
||||
/*
|
||||
* Locking macros
|
||||
*/
|
||||
#define THR_LOCK(m) \
|
||||
#define UMTX_LOCK(m) \
|
||||
do { \
|
||||
if (umtx_lock((m), curthread->thr_id) != 0) \
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#define THR_TRYLOCK(m, r) \
|
||||
#define UMTX_TRYLOCK(m, r) \
|
||||
do { \
|
||||
(r) = umtx_trylock((m), curthread->thr_id); \
|
||||
if ((r) != 0 && (r) != EBUSY) \
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#define THR_UNLOCK(m) \
|
||||
#define UMTX_UNLOCK(m) \
|
||||
do { \
|
||||
if (umtx_unlock((m), curthread->thr_id) != 0) \
|
||||
abort(); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user