- 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.
This commit is contained in:
jeff 2003-04-01 22:41:41 +00:00
parent 1aca38cd91
commit afdf14858f
3 changed files with 8 additions and 38 deletions

View File

@ -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);

View File

@ -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);
}
/*

View File

@ -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);
}