summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2003-06-29 23:51:04 +0000
committermtm <mtm@FreeBSD.org>2003-06-29 23:51:04 +0000
commit7f75cc45e943577f1bfd1324bb39e212b9531d54 (patch)
treee9bf941cb7bc23c1c5b2341a239af1a9b41cf044 /lib
parent39a4899732da552e6e0de76201566ee295c841fc (diff)
downloadFreeBSD-src-7f75cc45e943577f1bfd1324bb39e212b9531d54.zip
FreeBSD-src-7f75cc45e943577f1bfd1324bb39e212b9531d54.tar.gz
Sweep through pthread locking and use the new locking primitives for
libthr.
Diffstat (limited to 'lib')
-rw-r--r--lib/libthr/thread/thr_cancel.c4
-rw-r--r--lib/libthr/thread/thr_detach.c6
-rw-r--r--lib/libthr/thread/thr_exit.c4
-rw-r--r--lib/libthr/thread/thr_gc.c6
-rw-r--r--lib/libthr/thread/thr_join.c13
-rw-r--r--lib/libthr/thread/thr_kern.c4
-rw-r--r--lib/libthr/thread/thr_mutex.c4
7 files changed, 21 insertions, 20 deletions
diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c
index 7e1bace..311cf1e 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 23e985f..6161e86 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 bea7874..441e730 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 e2aa753..0948996 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 2a5433a..8b57978 100644
--- a/lib/libthr/thread/thr_join.c
+++ b/lib/libthr/thread/thr_join.c
@@ -33,6 +33,7 @@
*/
#include <errno.h>
#include <pthread.h>
+#include <stdlib.h>
#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 4a60bfe..481cc83 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 40921ec6..067f0f0 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);
OpenPOWER on IntegriCloud