diff options
author | deischen <deischen@FreeBSD.org> | 2003-04-18 05:04:16 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2003-04-18 05:04:16 +0000 |
commit | 5d56aa9cb2bdbe0a18bafbdbb6eb8cf6a46beb79 (patch) | |
tree | 46bc1e113ddc7c1ed88e4fa724039df8664c963a /lib/libpthread/thread/thr_spinlock.c | |
parent | e68f624d876da04bfb6860b450593c77d80368bd (diff) | |
download | FreeBSD-src-5d56aa9cb2bdbe0a18bafbdbb6eb8cf6a46beb79.zip FreeBSD-src-5d56aa9cb2bdbe0a18bafbdbb6eb8cf6a46beb79.tar.gz |
Revamp libpthread so that it has a chance of working in an SMP
environment. This includes support for multiple KSEs and KSEGs.
The ability to create more than 1 KSE via pthread_setconcurrency()
is in the works as well as support for PTHREAD_SCOPE_SYSTEM threads.
Those should come shortly.
There are still some known issues which davidxu and I are working
on, but it'll make it easier for us by committing what we have.
This library now passes all of the ACE tests that libc_r passes
with the exception of one. It also seems to work OK with KDE
including konqueror, kwrite, etc. I haven't been able to get
mozilla to run due to lack of java plugin, so I'd be interested
to see how it works with that.
Reviewed by: davidxu
Diffstat (limited to 'lib/libpthread/thread/thr_spinlock.c')
-rw-r--r-- | lib/libpthread/thread/thr_spinlock.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/lib/libpthread/thread/thr_spinlock.c b/lib/libpthread/thread/thr_spinlock.c index ad7b222..cb71a46 100644 --- a/lib/libpthread/thread/thr_spinlock.c +++ b/lib/libpthread/thread/thr_spinlock.c @@ -41,9 +41,14 @@ #include <unistd.h> #include <libc_private.h> - +#include "spinlock.h" #include "thr_private.h" +/* + * These are for compatability only. Spinlocks of this type + * are deprecated. + */ + void _spinunlock(spinlock_t *lck) { @@ -60,20 +65,14 @@ _spinunlock(spinlock_t *lck) void _spinlock(spinlock_t *lck) { - struct pthread *curthread = _get_curthread(); - /* * Try to grab the lock and loop if another thread grabs * it before we do. */ while(_atomic_lock(&lck->access_lock)) { - /* Block the thread until the lock. */ - curthread->data.spinlock = lck; - _thread_kern_sched_state(PS_SPINBLOCK, __FILE__, __LINE__); + while (lck->access_lock) + ; } - - /* The running thread now owns the lock: */ - lck->lock_owner = (long) curthread; } /* @@ -89,30 +88,12 @@ _spinlock(spinlock_t *lck) void _spinlock_debug(spinlock_t *lck, char *fname, int lineno) { - struct pthread *curthread = _get_curthread(); - int cnt = 0; - /* * Try to grab the lock and loop if another thread grabs * it before we do. */ while(_atomic_lock(&lck->access_lock)) { - cnt++; - if (cnt > 100) { - char str[256]; - snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", getprogname(), curthread, lck, fname, lineno, lck->fname, lck->lineno); - __sys_write(2,str,strlen(str)); - __sleep(1); - cnt = 0; - } - - /* Block the thread until the lock. */ - curthread->data.spinlock = lck; - _thread_kern_sched_state(PS_SPINBLOCK, fname, lineno); + while (lck->access_lock) + ; } - - /* The running thread now owns the lock: */ - lck->lock_owner = (long) curthread; - lck->fname = fname; - lck->lineno = lineno; } |