summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2003-05-23 23:39:31 +0000
committermtm <mtm@FreeBSD.org>2003-05-23 23:39:31 +0000
commit3c92bdad80f3c5a47974bb2498852b95bb93bab5 (patch)
tree1a11ef81d4552811d60feb14870b307d678c5b8c
parent7cd751dbd6cdde4a9ed12d2ef1578f4ecc3cd934 (diff)
downloadFreeBSD-src-3c92bdad80f3c5a47974bb2498852b95bb93bab5.zip
FreeBSD-src-3c92bdad80f3c5a47974bb2498852b95bb93bab5.tar.gz
Add two functions: _spinlock_pthread() and _spinunlock_pthread()
that take the address of a struct pthread as their first argument. _spin[un]lock() just become wrappers arround these two functions. These new functions are for use in situations where curthread can't be used. One example is _thread_retire(), where we invalidate the array index curthread uses to get its pointer.. Approved by: re/blanket libthr
-rw-r--r--lib/libthr/arch/i386/i386/_setcurthread.c6
-rw-r--r--lib/libthr/thread/thr_private.h2
-rw-r--r--lib/libthr/thread/thr_spinlock.c16
3 files changed, 20 insertions, 4 deletions
diff --git a/lib/libthr/arch/i386/i386/_setcurthread.c b/lib/libthr/arch/i386/i386/_setcurthread.c
index 69a5e8f..0483120 100644
--- a/lib/libthr/arch/i386/i386/_setcurthread.c
+++ b/lib/libthr/arch/i386/i386/_setcurthread.c
@@ -75,13 +75,15 @@ ldt_init(void)
void
_retire_thread(void *entry)
{
- _SPINLOCK(&ldt_lock);
+ pthread_t thr = curthread;
+
+ _spinlock_pthread(thr, &ldt_lock);
if (ldt_free == NULL)
*(void **)entry = NULL;
else
*(void **)entry = *ldt_free;
ldt_free = entry;
- _SPINUNLOCK(&ldt_lock);
+ _spinunlock_pthread(thr, &ldt_lock);
}
void *
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 10fdda0..b02df32 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -713,6 +713,8 @@ int _pthread_mutexattr_settype(pthread_mutexattr_t *, int);
int _pthread_once(pthread_once_t *, void (*) (void));
pthread_t _pthread_self(void);
int _pthread_setspecific(pthread_key_t, const void *);
+inline void _spinlock_pthread(pthread_t, spinlock_t *);
+inline void _spinunlock_pthread(pthread_t, spinlock_t *);
void _thread_exit(char *, int, char *);
void _thread_exit_cleanup(void);
void *_thread_cleanup(pthread_t);
diff --git a/lib/libthr/thread/thr_spinlock.c b/lib/libthr/thread/thr_spinlock.c
index 259977a..ff9b9e0 100644
--- a/lib/libthr/thread/thr_spinlock.c
+++ b/lib/libthr/thread/thr_spinlock.c
@@ -47,7 +47,13 @@
void
_spinunlock(spinlock_t *lck)
{
- if (umtx_unlock((struct umtx *)lck, curthread->thr_id))
+ _spinunlock_pthread(curthread, lck);
+}
+
+inline void
+_spinunlock_pthread(pthread_t pthread, spinlock_t *lck)
+{
+ if (umtx_unlock((struct umtx *)lck, pthread->thr_id))
abort();
}
@@ -60,7 +66,13 @@ _spinunlock(spinlock_t *lck)
void
_spinlock(spinlock_t *lck)
{
- if (umtx_lock((struct umtx *)lck, curthread->thr_id))
+ _spinlock_pthread(curthread, lck);
+}
+
+inline void
+_spinlock_pthread(pthread_t pthread, spinlock_t *lck)
+{
+ if (umtx_lock((struct umtx *)lck, pthread->thr_id))
abort();
}
OpenPOWER on IntegriCloud