From owner-freebsd-hackers Thu May 9 18:30:57 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id SAA27192 for hackers-outgoing; Thu, 9 May 1996 18:30:57 -0700 (PDT) Received: from yokogawa.co.jp (yhqfm.yokogawa.co.jp [202.33.29.34]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id SAA27183 for ; Thu, 9 May 1996 18:30:54 -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 KAA19984 for ; Fri, 10 May 1996 10:30:41 +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 KAA08433; Fri, 10 May 1996 10:30:40 +0900 (JST) Received: from sapphire by leia.pa.yokogawa.co.jp (1.38.193.4/6.4J.6-YOKOGAWA/pa) id AA28800; Fri, 10 May 1996 10:30:38 +0900 Received: from localhost by sapphire.pa.yokogawa.co.jp (8.6.12/3.3Wb) id KAA01256; Fri, 10 May 1996 10:31:38 +0900 Message-Id: <199605100131.KAA01256@sapphire.pa.yokogawa.co.jp> To: freebsd-hackers@freebsd.org Cc: taketomi@pa.yokogawa.co.jp Subject: a problem of setitimer() From: =?ISO-2022-JP?B?GyRCRURDZkh+SmY7UhsoQg==?= X-Mailer: Mew version 1.03 on Emacs 19.28.2, Mule 2.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Date: Fri, 10 May 1996 10:31:37 +0900 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi all, I'm running FreeBSD-2.1.0R. I found the problem of realitexpire() [sys/kern/kern_time.c]. If the time is late, the process which uses the system call setitimer() can't get SIGALARM until the next timeout has come. For example, the current time is 7:30 and the next timeout is 7:32, then the time is changed to 7:15. The process gets SIGALARM at 7:32, not at 7:17. I suggest following coding. How about? void realitexpire(arg) void *arg; { register struct proc *p; int s; p = (struct proc *)arg; psignal(p, SIGALRM); if (!timerisset(&p->p_realtimer.it_interval)) { timerclear(&p->p_realtimer.it_value); return; } /* vvv The following added vvv */ if (timercmp(&p->p_realtimer.it_value, &time, >)) { for (;;) { s = splclock(); timevalsub(&p->p_realtimer.it_value, &p->p_realtimer.it_interval); if (timercmp(&p->p_realtimer.it_value, &time, <)) { splx(s); break; } splx(s); } } /* ^^^ The above added ^^^ */ for (;;) { s = splclock(); timevaladd(&p->p_realtimer.it_value, &p->p_realtimer.it_interval); if (timercmp(&p->p_realtimer.it_value, &time, >)) { timeout(realitexpire, (caddr_t)p, hzto(&p->p_realtimer.it_value) - 1); splx(s); return; } splx(s); } } Thank you in advance. -- Mihoko Tanaka