From c6f2aed1029befe1f0e3d8a355ef7fa7500a39b3 Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Mon, 26 Feb 2001 01:05:33 +0000 Subject: [PATCH] Limit threads clock resolution to no less than 1000usec (1000Hz). PR: 25300 Submitted by: Tom Pavel (in part) --- lib/libc_r/uthread/pthread_private.h | 1 + lib/libc_r/uthread/uthread_init.c | 3 ++- lib/libkse/thread/thr_init.c | 3 ++- lib/libkse/thread/thr_private.h | 1 + lib/libpthread/thread/thr_init.c | 3 ++- lib/libpthread/thread/thr_private.h | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h index 7a37de8957b..8e04bd5bb14 100644 --- a/lib/libc_r/uthread/pthread_private.h +++ b/lib/libc_r/uthread/pthread_private.h @@ -459,6 +459,7 @@ enum pthread_susp { * Clock resolution in microseconds. */ #define CLOCK_RES_USEC 10000 +#define CLOCK_RES_USEC_MIN 1000 /* * Time slice period in microseconds. diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c index c92efe3e859..80ec23147e1 100644 --- a/lib/libc_r/uthread/uthread_init.c +++ b/lib/libc_r/uthread/uthread_init.c @@ -414,7 +414,8 @@ _thread_init(void) mib[1] = KERN_CLOCKRATE; len = sizeof (struct clockinfo); if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0) - _clock_res_usec = clockinfo.tick; + _clock_res_usec = clockinfo.tick > CLOCK_RES_USEC_MIN ? + clockinfo.tick : CLOCK_RES_USEC_MIN; /* Get the table size: */ if ((_thread_dtablesize = getdtablesize()) < 0) { diff --git a/lib/libkse/thread/thr_init.c b/lib/libkse/thread/thr_init.c index c92efe3e859..80ec23147e1 100644 --- a/lib/libkse/thread/thr_init.c +++ b/lib/libkse/thread/thr_init.c @@ -414,7 +414,8 @@ _thread_init(void) mib[1] = KERN_CLOCKRATE; len = sizeof (struct clockinfo); if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0) - _clock_res_usec = clockinfo.tick; + _clock_res_usec = clockinfo.tick > CLOCK_RES_USEC_MIN ? + clockinfo.tick : CLOCK_RES_USEC_MIN; /* Get the table size: */ if ((_thread_dtablesize = getdtablesize()) < 0) { diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h index 7a37de8957b..8e04bd5bb14 100644 --- a/lib/libkse/thread/thr_private.h +++ b/lib/libkse/thread/thr_private.h @@ -459,6 +459,7 @@ enum pthread_susp { * Clock resolution in microseconds. */ #define CLOCK_RES_USEC 10000 +#define CLOCK_RES_USEC_MIN 1000 /* * Time slice period in microseconds. diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c index c92efe3e859..80ec23147e1 100644 --- a/lib/libpthread/thread/thr_init.c +++ b/lib/libpthread/thread/thr_init.c @@ -414,7 +414,8 @@ _thread_init(void) mib[1] = KERN_CLOCKRATE; len = sizeof (struct clockinfo); if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0) - _clock_res_usec = clockinfo.tick; + _clock_res_usec = clockinfo.tick > CLOCK_RES_USEC_MIN ? + clockinfo.tick : CLOCK_RES_USEC_MIN; /* Get the table size: */ if ((_thread_dtablesize = getdtablesize()) < 0) { diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index 7a37de8957b..8e04bd5bb14 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -459,6 +459,7 @@ enum pthread_susp { * Clock resolution in microseconds. */ #define CLOCK_RES_USEC 10000 +#define CLOCK_RES_USEC_MIN 1000 /* * Time slice period in microseconds.