From owner-freebsd-hackers Mon Sep 9 03:42:11 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id DAA13974 for hackers-outgoing; Mon, 9 Sep 1996 03:42:11 -0700 (PDT) Received: from yokogawa.co.jp (yhqfm.yokogawa.co.jp [202.33.29.34]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id DAA13954 for ; Mon, 9 Sep 1996 03:41:48 -0700 (PDT) Received: from sjc.yokogawa.co.jp.yokogawa.co.jp ([133.140.4.100]) by yokogawa.co.jp (8.6.9+2.4Wb3/3.3Wb4-firewall:08/09/94) with ESMTP id TAA22703 for ; Mon, 9 Sep 1996 19:41:32 +0900 Received: from leia.pa.yokogawa.co.jp by sjc.yokogawa.co.jp.yokogawa.co.jp (8.7.1+2.6Wbeta4/6.4J.6-YOKOGAWA-R/GW) id TAA18256; Mon, 9 Sep 1996 19:41:30 +0900 (JST) Received: from sapphire by leia.pa.yokogawa.co.jp (1.38.193.4/6.4J.6-YOKOGAWA/pa) id AA14253; Mon, 9 Sep 1996 19:41:30 +0900 Received: from localhost by sapphire.pa.yokogawa.co.jp (8.6.12/3.3Wb) id TAA11154; Mon, 9 Sep 1996 19:42:26 +0900 Message-Id: <199609091042.TAA11154@sapphire.pa.yokogawa.co.jp> To: freebsd-hackers@freebsd.org Subject: Re: a problem of setitimer() Reply-To: mihoko@pa.yokogawa.co.jp In-Reply-To: Your message of "Fri, 10 May 1996 18:20:25 +1000" References: <199605100820.SAA03647@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii From: Mihoko Tanaka X-Mailer: Mew version 1.06 on Emacs 19.28.2, Mule 2.3 Date: Mon, 09 Sep 1996 19:42:26 +0900 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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