Subject: Re: time broken on current kernel
To: <>
From: David Laight <david@l8s.co.uk>
List: current-users
Date: 03/14/2003 19:17:34
> Oh - the child times were completely wrong before, they were only
> added in if the parent asked for the childs resource use in exit().
>
> Since I know how this code works, I'll sort out a fix shortly.
Yes - it wasn't my fault, the bug has been there for (probably) ever.
My test kernel tree won't show it because I changed p->p_rtime from
struct timeval to a uint64_t (of usecs).
This fixes it:
Index: kern_resource.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_resource.c,v
retrieving revision 1.69
diff -u -p -r1.69 kern_resource.c
--- kern_resource.c 2003/03/05 11:44:01 1.69
+++ kern_resource.c 2003/03/14 19:14:20
@@ -421,13 +422,18 @@ calcru(p, up, sp, ip)
microtime(&tv);
sec += tv.tv_sec - spc->spc_runtime.tv_sec;
usec += tv.tv_usec - spc->spc_runtime.tv_usec;
+ if ((long)usec < 0) {
+ usec += 1000000;
+ sec--;
+ }
}
}
tot = st + ut + it;
if (tot == 0) {
/* No ticks, so can't use to share time out, split 50-50 */
- if (usec > 1000000 && (sec & 1)) {
+ if (usec >= 1000000 && (sec & 1)) {
usec -= 1000000;
sec++;
} else {
The second bug is mine :-( but extremely unlikely)
David
--
David Laight: david@l8s.co.uk