From d5e6e059f60c76132da18a9bd58d384f0a204529 Mon Sep 17 00:00:00 2001 From: Thomas Nordin Date: Wed, 12 Dec 2001 19:06:48 +0000 Subject: Handle itimer intervals smaller than the resolution of the clock; pr#2182. --- sys/kern/kern_time.c | 19 +++++++++++++++++-- 1 file 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 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); } @@ -552,6 +555,18 @@ itimerfix(tv) return (0); } +/* + * 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, -- cgit v1.2.3