Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Aug 1998 10:36:20 +0200
From:      Stefan Eggers <seggers@semyam.dinoco.de>
To:        Brian Feldman <green@unixhelp.org>
Cc:        seggers@semyam.dinoco.de, freebsd-current@FreeBSD.ORG
Subject:   Re: 13 months of user time? 
Message-ID:  <199808210836.KAA02477@semyam.dinoco.de>
In-Reply-To: Your message of "Thu, 20 Aug 1998 02:08:08 EDT." <Pine.BSF.4.02.9808200203190.24018-100000@zone.syracuse.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
> SIGXCPU kill problem could try putting the following in kern/kern_synch.c
> line 638:

I think better not this one as that is a safe way to a panic IMHO.  A
version I think does what you intend this to do I add below.  It is
untested code I just added while writing the mail.

> if (switchtime.tv_usec < p->p_switchtime.tv_usec ||
>     switchtime.tv_sec < p->p_switchtime.tv_sec)
> 	panic("bogus microuptime twiddling");
> 
> And see if we get some nice panics and cores. Is it worth a shot? I've

As far as I can see the timeval in the process structure is a real
timeval and not abused to be something else.  So tv_usec contains the
micro seconds part and tv_sec the seconds.

Let's assume that p->p_switchtime.tv_usec contains 999999 now and
p->p_switchtime.tv_sec is 0.  Lets suppose the time continues a little
bit and when we reach the if statement switchtime.tv_usec might
contain 0 and switchtime.tv_sec 1.  The time didn't go backward but
with the code above causes a panic.

> never gotten a SIGXCPU out of place, so my machine wouldn't be the one to
> test this on.

And I don't think you want the test this way, anyway.  ;-)

One has first to calculate a 64 bit integer from the seconds and micro
seconds and then compare the two resulting numbers.  With that it
could actually detect switchtime going backward.

Something like this:

int64_t time1, time2;
[...]
time1 = switchtime.tv_usec + switchtime.tv_sec * (int64_t)1000000;
time2 = p->p_switchtime.tv_usec + p->p_switchtime.tv_sec * (int64_t)1000000;
if (time1 < time2)
	panic("Ooops!  Switchtime going backward!");

Stefan.
-- 
Stefan Eggers                 Lu4 yao2 zhi1 ma3 li4,
Max-Slevogt-Str. 1            ri4 jiu3 jian4 ren2 xin1.
51109 Koeln
Federal Republic of Germany

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808210836.KAA02477>