diff options
author | jeff <jeff@FreeBSD.org> | 2003-04-01 22:41:41 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2003-04-01 22:41:41 +0000 |
commit | 4b5aacdfc871360134c035a6c5e6010072f105a6 (patch) | |
tree | 57e53bd64ff482e07d9e7557a1aa98cbe03389c6 /lib/libthr | |
parent | 886873a91d65f6b2ba6dd2c7bea20bf42088c8f5 (diff) | |
download | FreeBSD-src-4b5aacdfc871360134c035a6c5e6010072f105a6.zip FreeBSD-src-4b5aacdfc871360134c035a6c5e6010072f105a6.tar.gz |
- Don't drop and reacquire giant in thread_suspend(). Change callers to do
this manually. This will facilitate the unrolling of giant.
- Don't allow giant to recurse anymore. This should never happen.
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_cond.c | 2 | ||||
-rw-r--r-- | lib/libthr/thread/thr_join.c | 2 | ||||
-rw-r--r-- | lib/libthr/thread/thr_kern.c | 42 |
3 files changed, 8 insertions, 38 deletions
diff --git a/lib/libthr/thread/thr_cond.c b/lib/libthr/thread/thr_cond.c index 0327575..6bee687 100644 --- a/lib/libthr/thread/thr_cond.c +++ b/lib/libthr/thread/thr_cond.c @@ -275,12 +275,14 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, } PTHREAD_SET_STATE(curthread, PS_COND_WAIT); + GIANT_UNLOCK(curthread); rval = _thread_suspend(curthread, time); if (rval == -1) { printf("foo"); fflush(stdout); abort(); } + GIANT_LOCK(curthread); done = (seqno != (*cond)->c_seqno); diff --git a/lib/libthr/thread/thr_join.c b/lib/libthr/thread/thr_join.c index e22408c..ab46f0a 100644 --- a/lib/libthr/thread/thr_join.c +++ b/lib/libthr/thread/thr_join.c @@ -124,7 +124,9 @@ _pthread_join(pthread_t pthread, void **thread_return) while (curthread->join_status.thread == pthread) { PTHREAD_SET_STATE(curthread, PS_JOIN); /* Wait for our signal to wake up. */ + GIANT_UNLOCK(curthread); _thread_suspend(curthread, NULL); + GIANT_LOCK(curthread); } /* diff --git a/lib/libthr/thread/thr_kern.c b/lib/libthr/thread/thr_kern.c index 1ad8526..2f9e086 100644 --- a/lib/libthr/thread/thr_kern.c +++ b/lib/libthr/thread/thr_kern.c @@ -50,9 +50,6 @@ static sigset_t restore; -pthread_t _giant_owner = NULL; -int _giant_count = 0; - void GIANT_LOCK(pthread_t pthread) { @@ -60,11 +57,6 @@ GIANT_LOCK(pthread_t pthread) sigset_t sav; int error; - if (_giant_owner == pthread) { - abort(); - _giant_count++; - } - /* * Block all signals. */ @@ -88,9 +80,6 @@ GIANT_LOCK(pthread_t pthread) abort(); } - _giant_owner = pthread; - _giant_count = 1; - restore = sav; } @@ -100,14 +89,6 @@ GIANT_UNLOCK(pthread_t pthread) sigset_t set; int error; - if (_giant_owner != pthread) - abort(); - - if (--_giant_count > 0) - return; - - _giant_owner = NULL; - /* * restore is protected by giant. We could restore our signal state * incorrectly if someone else set restore between unlocking giant @@ -135,13 +116,12 @@ GIANT_UNLOCK(pthread_t pthread) } int -_thread_suspend(pthread_t thread, struct timespec *abstime) +_thread_suspend(pthread_t pthread, struct timespec *abstime) { struct timespec remaining; struct timespec *ts; siginfo_t info; sigset_t set; - int giant_count; /* Saved recursion */ int error; /* @@ -150,6 +130,9 @@ _thread_suspend(pthread_t thread, struct timespec *abstime) SIGFILLSET(set); SIGDELSET(set, SIGTHR); + /* + * Compute the remainder of the run time. + */ if (abstime) { struct timespec now; struct timeval tv; @@ -163,26 +146,9 @@ _thread_suspend(pthread_t thread, struct timespec *abstime) } else ts = NULL; - /* - * Save and unroll the recursion count. - */ - giant_count = _giant_count; - _giant_count = 1; - GIANT_UNLOCK(thread); - error = sigtimedwait(&set, &info, ts); if (error == -1) error = errno; - /* XXX Kernel bug. */ - if (error == EINTR) - error = 0; - - /* - * Restore the recursion count. - */ - GIANT_LOCK(thread); - _giant_count = giant_count; - return (error); } |