summaryrefslogtreecommitdiffstats
path: root/lib/libc_r
diff options
context:
space:
mode:
authordt <dt@FreeBSD.org>1998-10-09 19:01:30 +0000
committerdt <dt@FreeBSD.org>1998-10-09 19:01:30 +0000
commita3544f2edb31acfc1c2fec1e96e88f423e51a57f (patch)
tree17a570d16886224bb1e0981ddfc2971902a7a7ac /lib/libc_r
parentb9c44f55137fecbbad921b314afe7b67556bd3c0 (diff)
downloadFreeBSD-src-a3544f2edb31acfc1c2fec1e96e88f423e51a57f.zip
FreeBSD-src-a3544f2edb31acfc1c2fec1e96e88f423e51a57f.tar.gz
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." <dick@tar.com>
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/uthread/uthread_create.c3
-rw-r--r--lib/libc_r/uthread/uthread_kern.c15
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/libc_r/uthread/uthread_create.c b/lib/libc_r/uthread/uthread_create.c
index c7ddeb2..4169461 100644
--- a/lib/libc_r/uthread/uthread_create.c
+++ b/lib/libc_r/uthread/uthread_create.c
@@ -223,6 +223,9 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void
_thread_start(void)
{
+ /* We just left the scheduler via longjmp: */
+ _thread_kern_in_sched = 0;
+
/* Run the current thread's start routine with argument: */
pthread_exit(_thread_run->start_routine(_thread_run->arg));
diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c
index da125cd..22746c7 100644
--- a/lib/libc_r/uthread/uthread_kern.c
+++ b/lib/libc_r/uthread/uthread_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 <errno.h>
@@ -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
/*
OpenPOWER on IntegriCloud