summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2003-06-29 00:12:40 +0000
committermtm <mtm@FreeBSD.org>2003-06-29 00:12:40 +0000
commitdffd0ee5d1bb64bc51ea5d11969a289a60abed63 (patch)
tree8f176ce8a22cedcbeffe67b403b6510d65dc36bb /lib/libthr
parent348e423dd913fabaea56f15eecca3d155723ee08 (diff)
downloadFreeBSD-src-dffd0ee5d1bb64bc51ea5d11969a289a60abed63.zip
FreeBSD-src-dffd0ee5d1bb64bc51ea5d11969a289a60abed63.tar.gz
The move to _retire() a thread in the GC instead of in the thread's
exit function has invalidated the need for _spin[un]lock_pthread(). The _spin[un]lock() functions can now dereference curthread without the danger that the ldtentry containing the pointer to the thread has been cleared out from under them.
Diffstat (limited to 'lib/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.c18
3 files changed, 5 insertions, 21 deletions
diff --git a/lib/libthr/arch/i386/i386/_setcurthread.c b/lib/libthr/arch/i386/i386/_setcurthread.c
index 81db3e9..1960c0e 100644
--- a/lib/libthr/arch/i386/i386/_setcurthread.c
+++ b/lib/libthr/arch/i386/i386/_setcurthread.c
@@ -75,15 +75,13 @@ ldt_init(void)
void
_retire_thread(void *entry)
{
- pthread_t thr = curthread;
-
- _spinlock_pthread(thr, &ldt_lock);
+ _spinlock(&ldt_lock);
if (ldt_free == NULL)
*(void **)entry = NULL;
else
*(void **)entry = *ldt_free;
ldt_free = entry;
- _spinunlock_pthread(thr, &ldt_lock);
+ _spinunlock(&ldt_lock);
}
void *
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 6540bef..9989342 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -746,8 +746,6 @@ int _pthread_once(pthread_once_t *, void (*) (void));
pthread_t _pthread_self(void);
int _pthread_setspecific(pthread_key_t, const void *);
int _spintrylock(spinlock_t *);
-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 0f9cb6b..53e9851 100644
--- a/lib/libthr/thread/thr_spinlock.c
+++ b/lib/libthr/thread/thr_spinlock.c
@@ -47,13 +47,7 @@
void
_spinunlock(spinlock_t *lck)
{
- _spinunlock_pthread(curthread, lck);
-}
-
-inline void
-_spinunlock_pthread(pthread_t pthread, spinlock_t *lck)
-{
- if (umtx_unlock((struct umtx *)lck, pthread->thr_id))
+ if (umtx_unlock((struct umtx *)lck, curthread->thr_id))
abort();
}
@@ -66,7 +60,8 @@ _spinunlock_pthread(pthread_t pthread, spinlock_t *lck)
void
_spinlock(spinlock_t *lck)
{
- _spinlock_pthread(curthread, lck);
+ if (umtx_lock((struct umtx *)lck, curthread->thr_id))
+ abort();
}
int
@@ -79,13 +74,6 @@ _spintrylock(spinlock_t *lck)
return (error);
}
-inline void
-_spinlock_pthread(pthread_t pthread, spinlock_t *lck)
-{
- if (umtx_lock((struct umtx *)lck, pthread->thr_id))
- abort();
-}
-
/*
* Lock a location for the running thread. Yield to allow other
* threads to run if this thread is blocked because the lock is
OpenPOWER on IntegriCloud