Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 May 1996 10:31:37 +0900
From:      =?ISO-2022-JP?B?GyRCRURDZkh+SmY7UhsoQg==?= <mihoko@pa.yokogawa.co.jp>
To:        freebsd-hackers@freebsd.org
Cc:        taketomi@pa.yokogawa.co.jp
Subject:   a problem of setitimer()
Message-ID:  <199605100131.KAA01256@sapphire.pa.yokogawa.co.jp>

next in thread | raw e-mail | index | archive | help

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
<mihoko@pa.yokogawa.co.jp>




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