From e9d0431f0bacfa6eb8503a6dbf56f530caa8776a Mon Sep 17 00:00:00 2001 From: Jonathan Mini Date: Sun, 24 Nov 2002 06:45:45 +0000 Subject: [PATCH] Schedule spinlocked threads by moving them through the work queue, instead of the wait queue. Approved by: re (blanket) Stolen from: davidxu --- lib/libkse/thread/thr_kern.c | 17 +++++++++++++++-- lib/libpthread/thread/thr_kern.c | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index 087e1df88ea8..0747cffb50a3 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -166,7 +166,18 @@ _thread_kern_sched(void) case PS_SPINBLOCK: /* Increment spinblock count. */ _spinblock_count++; - /*FALLTHROUGH*/ + + /* No timeouts for these states. */ + curthread->wakeup_time.tv_sec = -1; + curthread->wakeup_time.tv_nsec = -1; + + /* Restart the time slice. */ + curthread->slice_usec = -1; + + /* Insert into the work queue. */ + PTHREAD_WORKQ_INSERT(curthread); + break; + case PS_DEADLOCK: case PS_JOIN: case PS_MUTEX_WAIT: @@ -288,7 +299,9 @@ _thread_kern_scheduler(struct kse_mailbox *km) access_lock == 0) { PTHREAD_WAITQ_CLEARACTIVE(); PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread, + PTHREAD_PRIOQ_INSERT_TAIL( + pthread); + PTHREAD_SET_STATE(pthread, PS_RUNNING); PTHREAD_WAITQ_SETACTIVE(); diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index 087e1df88ea8..0747cffb50a3 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -166,7 +166,18 @@ _thread_kern_sched(void) case PS_SPINBLOCK: /* Increment spinblock count. */ _spinblock_count++; - /*FALLTHROUGH*/ + + /* No timeouts for these states. */ + curthread->wakeup_time.tv_sec = -1; + curthread->wakeup_time.tv_nsec = -1; + + /* Restart the time slice. */ + curthread->slice_usec = -1; + + /* Insert into the work queue. */ + PTHREAD_WORKQ_INSERT(curthread); + break; + case PS_DEADLOCK: case PS_JOIN: case PS_MUTEX_WAIT: @@ -288,7 +299,9 @@ _thread_kern_scheduler(struct kse_mailbox *km) access_lock == 0) { PTHREAD_WAITQ_CLEARACTIVE(); PTHREAD_WORKQ_REMOVE(pthread); - PTHREAD_NEW_STATE(pthread, + PTHREAD_PRIOQ_INSERT_TAIL( + pthread); + PTHREAD_SET_STATE(pthread, PS_RUNNING); PTHREAD_WAITQ_SETACTIVE();