Date: Mon, 09 Sep 1996 19:42:26 +0900 From: Mihoko Tanaka <mihoko@pa.yokogawa.co.jp> To: freebsd-hackers@freebsd.org Subject: Re: a problem of setitimer() Message-ID: <199609091042.TAA11154@sapphire.pa.yokogawa.co.jp> In-Reply-To: Your message of "Fri, 10 May 1996 18:20:25 %2B1000" References: <199605100820.SAA03647@godzilla.zeta.org.au>
index | next in thread | previous in thread | raw e-mail
Hello,
Long long ago, :-)
I asked the following question and got some answer from Mr. Evans
about it.
bde> >I'm running FreeBSD-2.1.0R.
bde> >I found the problem of realitexpire() [sys/kern/kern_time.c].
bde> >If the time is late, the process which uses the system call
bde> >setitimer() can't get SIGALARM until the next timeout has come.
bde>
bde> >For example, the current time is 7:30 and the next timeout is 7:32,
bde> >then the time is changed to 7:15.
bde> >The process gets SIGALARM at 7:32, not at 7:17.
bde>
bde> >I suggest following coding.
bde> >How about?
bde>
bde> I think the correct fix is to adjust all the timers in settimeofday().
bde> It now says /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
bde> and does nothing.
Why does it nothing ?
I agree that all the timers are adjusted in settimeofday() when
the current time is changed.
Or, the system is locked several times when we change the current
time on a large scale.
For instance, I change the current time to '9 Sep 1996' from '9 Sep
1999' by using 'date' command, (of course I know it's my silly
doings :-) )
then my freebsd has been locked for 5 minutes.
The kernel is looping in realitexpire() at that time because 'time'
has so big value.
How about the following patch ? (it's for -current.)
------------------------ cut here --------------------------------------
--- kern_time.c Mon Sep 9 19:27:30 1996
+++ kern_time.c.new Mon Sep 9 19:30:05 1996
@@ -56,6 +56,8 @@
*/
static void timevalfix __P((struct timeval *));
+static void recalc_realtimer(struct timeval);
+
#ifndef _SYS_SYSPROTO_H_
struct gettimeofday_args {
@@ -122,6 +124,7 @@
*/
delta.tv_sec = atv.tv_sec - time.tv_sec;
delta.tv_usec = atv.tv_usec - time.tv_usec;
+ recalc_realtimer(delta);
time = atv;
/*
* XXX should arrange for microtime() to agree with atv if
@@ -144,6 +147,21 @@
tz = atz;
return (0);
}
+
+static void
+recalc_realtimer(struct timeval delta)
+{
+ struct proc *p=(struct proc *)allproc;
+ int np=nprocs;
+
+ while(--np >=0) {
+ if (timerisset(&p->p_realtimer.it_value)) {
+ timevaladd(&p->p_realtimer.it_value, &delta);
+ timevalfix(&p->p_realtimer.it_value);
+ }
+ p = p->p_next;
+ }
+}
extern int tickadj; /* "standard" clock skew, us./tick */
int tickdelta; /* current clock skew, us. per tick */
------------------------ cut here --------------------------------------
--
Mihoko Tanaka
<mihoko@pa.yokogawa.co.jp>
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609091042.TAA11154>
