EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
<== Date ==> <== Thread ==>

Subject: Re: callbackRequestDelayed question
From: Michael Davidsaver via Core-talk <core-talk at aps.anl.gov>
To: Mark Rivers <rivers at cars.uchicago.edu>, "Johnson, Andrew N." <anj at anl.gov>
Cc: "core-talk at aps.anl.gov" <core-talk at aps.anl.gov>
Date: Wed, 12 Nov 2025 14:42:55 -0800
On 11/12/25 2:14 PM, Mark Rivers wrote:
Is it possible to override the value for epicsThreadSleepQuantum()?

Not without some amount of patching (see attached).

On Linux, the tick is reported by the kernel to each process through the aux. vector.  (cf. "AT_CLKTCK")

https://www.man7.org/linux/man-pages/man3/getauxval.3.html

circa Linux 6.12

$ git grep AT_CLKTCK
fs/binfmt_elf.c:        NEW_AUX_ENT(AT_CLKTCK, CLOCKS_PER_SEC);
fs/binfmt_elf_fdpic.c:  NEW_AUX_ENT(AT_CLKTCK,  CLOCKS_PER_SEC);
include/uapi/linux/auxvec.h:#define AT_CLKTCK 17        /* frequency at which times() increments */


$ git grep 'define\s*CLOCKS_PER_SEC'
arch/alpha/include/asm/param.h:# define CLOCKS_PER_SEC  USER_HZ /* frequency at which times() counts */
include/asm-generic/param.h:# define CLOCKS_PER_SEC     (USER_HZ)       /* in "ticks" like times() */


$ git grep 'define\s*USER_HZ'
arch/alpha/include/asm/param.h:# define USER_HZ 1024
include/asm-generic/param.h:# define USER_HZ    100             /* some user interfaces are */
tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c:#define USER_HZ               100
tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c:#define USER_HZ               100


So there we have it.  Static values.


From 50bc0bd3164664238ef699617e8fb076bc9949c4 Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <mdavidsaver at gmail.com>
Date: Thu, 29 Sep 2022 17:21:44 -0700
Subject: [PATCH] Avoid early expiration of timers on !vxWorks

---
 modules/libcom/src/timer/timer.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/libcom/src/timer/timer.cpp b/modules/libcom/src/timer/timer.cpp
index 679ca27ef..66cd45123 100644
--- a/modules/libcom/src/timer/timer.cpp
+++ b/modules/libcom/src/timer/timer.cpp
@@ -65,7 +65,16 @@ void timer::start ( epicsTimerNotify & notify, const epicsTime & expire )
 void timer::privateStart ( epicsTimerNotify & notify, const epicsTime & expire )
 {
     this->pNotify = & notify;
-    this->exp = expire - ( this->queue.notify.quantum () / 2.0 );
+    this->exp = expire
+#ifdef vxWorks
+            /* For historical reasons, round down here allows vxWorks timers
+             * which expire on every tick.  Otherwise, the fastest timer period
+             * is 2x the tick iterval.
+             * For other targets, this results in timers expiring early.
+             */
+            - ( this->queue.notify.quantum () / 2.0 )
+#endif
+            ;
 
     bool reschedualNeeded = false;
     if ( this->curState == stateActive ) {
-- 
2.47.3


References:
RE: callbackRequestDelayed question Mark Rivers via Core-talk
Re: callbackRequestDelayed question Michael Davidsaver via Core-talk
RE: callbackRequestDelayed question Mark Rivers via Core-talk
Re: callbackRequestDelayed question Michael Davidsaver via Core-talk
RE: callbackRequestDelayed question Mark Rivers via Core-talk

Navigate by Date:
Prev: RE: callbackRequestDelayed question Mark Rivers via Core-talk
Next: Build failed: EPICS Base 7 base-7.0-1947 AppVeyor via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
Navigate by Thread:
Prev: RE: callbackRequestDelayed question Mark Rivers via Core-talk
Next: Re: callbackRequestDelayed question Michael Davidsaver via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
ANJ, 12 Nov 2025 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·