From 77e718f7737732665c489a6a4b2dbaf6acc51b0c Mon Sep 17 00:00:00 2001 From: David Xu Date: Thu, 1 Dec 2005 07:56:15 +0000 Subject: [PATCH] 1. Set timer configuration values for sysconf(). 2. Set overrun limit to INT_MAX, report ERANGE error if overrun will be greater than INT_MAX. --- sys/kern/kern_time.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index e2be60391b63..4cba08fa65ef 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -51,6 +52,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include @@ -883,6 +886,9 @@ itimer_start(void) NULL, NULL, itimer_init, itimer_fini, UMA_ALIGN_PTR, 0); register_posix_clock(CLOCK_REALTIME, &rt_clock); register_posix_clock(CLOCK_MONOTONIC, &rt_clock); + p31b_setcfg(CTL_P1003_1B_TIMERS, 200112L); + p31b_setcfg(CTL_P1003_1B_DELAYTIMER_MAX, INT_MAX); + p31b_setcfg(CTL_P1003_1B_TIMER_MAX, TIMER_MAX); } int @@ -1408,7 +1414,10 @@ realtimer_expire(void *arg) timespecadd(&it->it_time.it_value, &it->it_time.it_interval); while (timespeccmp(&cts, &it->it_time.it_value, >=)) { - it->it_overrun++; + if (it->it_overrun < INT_MAX) + it->it_overrun++; + else + it->it_ksi.ksi_errno = ERANGE; timespecadd(&it->it_time.it_value, &it->it_time.it_interval); } @@ -1445,6 +1454,7 @@ itimer_fire(struct itimer *it) it->it_sigev.sigev_notify == SIGEV_THREAD_ID) { PROC_LOCK(p); if (!KSI_ONQ(&it->it_ksi)) { + it->it_ksi.ksi_errno = 0; ret = psignal_event(p, &it->it_sigev, &it->it_ksi); if (__predict_false(ret != 0)) { it->it_overrun++; @@ -1461,7 +1471,10 @@ itimer_fire(struct itimer *it) } } } else { - it->it_overrun++; + if (it->it_overrun < INT_MAX) + it->it_overrun++; + else + it->it_ksi.ksi_errno = ERANGE; } PROC_UNLOCK(p); }