diff options
author | Thomas Nordin <nordin@cvs.openbsd.org> | 2001-12-12 19:06:48 +0000 |
---|---|---|
committer | Thomas Nordin <nordin@cvs.openbsd.org> | 2001-12-12 19:06:48 +0000 |
commit | d5e6e059f60c76132da18a9bd58d384f0a204529 (patch) | |
tree | 08acf07a535b4529f9af61709c2f58d2846bbbb6 /sys | |
parent | fb3d03988d5a2c5038d4d129d2ce2ef8a2ecd9e5 (diff) |
Handle itimer intervals smaller than the resolution of the clock; pr#2182.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_time.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 60bbbcdae70..e3ce8ff76a2 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.24 2001/06/25 03:28:03 csapuntz Exp $ */ +/* $OpenBSD: kern_time.c,v 1.25 2001/12/12 19:06:47 nordin Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -56,6 +56,7 @@ #include <machine/cpu.h> void settime __P((struct timeval *)); +void itimerround __P((struct timeval *)); /* * Time of day and interval timer support. @@ -493,8 +494,10 @@ sys_setitimer(p, v, retval) timeout_add(&p->p_realit_to, timo); } p->p_realtimer = aitv; - } else + } else { + itimerround(&aitv.it_interval); p->p_stats->p_timer[SCARG(uap, which)] = aitv; + } splx(s); return (0); } @@ -553,6 +556,18 @@ itimerfix(tv) } /* + * Timer interval smaller than the resolution of the system clock are + * rounded up. + */ +void +itimerround(tv) + struct timeval *tv; +{ + if (tv->tv_sec == 0 && tv->tv_usec < tick) + tv->tv_usec = tick; +} + +/* * Decrement an interval timer by a specified number * of microseconds, which must be less than a second, * i.e. < 1000000. If the timer expires, then reload |