From a3544f2edb31acfc1c2fec1e96e88f423e51a57f Mon Sep 17 00:00:00 2001 From: dt Date: Fri, 9 Oct 1998 19:01:30 +0000 Subject: Fix some bugs in pthread scheduler: make pthread_yield() more reliable, threads always (I hope) preempted at least every 0.1 sec, as intended. PR: bin/7744 Submitted by: "Richard Seaman, Jr." --- lib/libkse/thread/thr_kern.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/libkse/thread/thr_kern.c') diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c index da125cd..22746c7 100644 --- a/lib/libkse/thread/thr_kern.c +++ b/lib/libkse/thread/thr_kern.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: uthread_kern.c,v 1.12 1998/09/07 21:55:01 alex Exp $ + * $Id: uthread_kern.c,v 1.13 1998/09/30 06:36:56 jb Exp $ * */ #include @@ -206,10 +206,12 @@ __asm__("fnsave %0": :"m"(*fdata)); * Accumulate the number of microseconds that this * thread has run for: */ - _thread_run->slice_usec += (_thread_run->last_inactive.tv_sec - - _thread_run->last_active.tv_sec) * 1000000 + - _thread_run->last_inactive.tv_usec - - _thread_run->last_active.tv_usec; + if (_thread_run->slice_usec != -1) { + _thread_run->slice_usec += (_thread_run->last_inactive.tv_sec - + _thread_run->last_active.tv_sec) * 1000000 + + _thread_run->last_inactive.tv_usec - + _thread_run->last_active.tv_usec; + } /* * Check if this thread has reached its allocated @@ -242,7 +244,7 @@ __asm__("fnsave %0": :"m"(*fdata)); * the last incremental priority check was * made: */ - else if (timercmp(&_thread_run->last_inactive, &kern_inc_prio_time, <)) { + else if (timercmp(&pthread->last_inactive, &kern_inc_prio_time, <)) { /* * Increment the incremental priority * for this thread in the hope that @@ -582,6 +584,7 @@ __asm__("fnsave %0": :"m"(*fdata)); * Do a sigreturn to restart the thread that * was interrupted by a signal: */ + _thread_kern_in_sched = 0; _thread_sys_sigreturn(&_thread_run->saved_sigcontext); } else /* -- cgit v1.1