From bc9e7c3b4227265a72363a3e2898afc0068ffd0d Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Mon, 27 Jul 1998 19:16:21 +0000 Subject: Fixed double counting of runtime after a process exits. The last timeslice of the exiting process was counted for both the exiting process and the next process to run if the next process runs immediately. Broken in: mostly in kern_clock.c rev.1.70 (1998/05/28) --- sys/kern/kern_resource.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sys/kern') diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index a19f489cc75b..1bad1d2f0471 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_resource.c,v 1.36 1998/05/17 11:52:43 phk Exp $ + * $Id: kern_resource.c,v 1.37 1998/05/28 09:30:18 phk Exp $ */ #include "opt_compat.h" @@ -524,6 +524,16 @@ calcru(p, up, sp, ip) microuptime(&tv); totusec += (tv.tv_usec - p->p_switchtime.tv_usec) + (tv.tv_sec - p->p_switchtime.tv_sec) * (int64_t)1000000; + + /* + * Copy the time that was just read to `switchtime' in case + * we are being called from exit1(). Exits don't go through + * mi_switch(), so `switchtime' doesn't get set in the normal + * way. We set it here instead of more cleanly in exit1() + * to avoid losing track of the time between the calls to + * microuptime(). + */ + switchtime = tv; } if (totusec < 0) { /* XXX no %qd in kernel. Truncate. */ -- cgit v1.2.3