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  <20192020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: epicsThreadSleep and epicsThreadSleepQuantum
From: "Konrad, Martin via Core-talk" <[email protected]>
To: EPICS Core Talk <[email protected]>
Date: Tue, 11 Jun 2019 03:31:31 +0000
Hi,
I noticed that on most modern Linux machines epicsThreadSleepQuantum()
returns 0.01. The Application Developer's Guide says:

"This function returns the minimum slumber interval obtainable with
epicsThreadSleep() in seconds. [...]"

Looking at the implementation of epicsThreadSleep() which for POSIX uses
nanosleep() I don't think this statement is true. On Linux systems
running kernels >=2.5.47 (?) nanosleep() leverages high resolution
timers and thus is generally able to provide a few orders of magnitude
finer granularity [1,2]. According to my understanding the jiffy
returned by epicsThreadSleepQuantum() is completely unrelated to the
high resolution timers used by nanosleep().

In Base as well as in support modules I found code that calls

epicsThreadSleep(epicsThreadSleepQuantum())

- apparently with the intention of sleeping for a minimum amount of
time. This might result in a much longer sleep than necessary
potentially adding unnecessary latency on modern systems.

It seems like I'm not the first one who's surprised by the way this
function behaves and it seems like it might be misbehaving on other
platforms as well [3,4].

I'm wondering if it would be better to return 0. Maybe only on systems
that support high res timers (not sure if there is a way to detect
this)? Any thoughts?

-Martin

[1] https://rt.wiki.kernel.org/index.php/High_resolution_timers
[2] https://elinux.org/High_Resolution_Timers
[3]
https://github.com/epics-modules/asyn/blob/master/documentation/RELEASE_NOTES.html#L686-L694
[4]
https://github.com/epics-modules/asyn/blob/e40a5185ba55ec7d8e848197c7e371ce1684f2e7/asyn/miscellaneous/asynShellCommands.c#L1189-L1229

-- 
Martin Konrad
Facility for Rare Isotope Beams
Michigan State University
640 South Shaw Lane
East Lansing, MI 48824-1321, USA
Tel. 517-908-7253
Email: [email protected]

Replies:
Re: epicsThreadSleep and epicsThreadSleepQuantum Mark Rivers via Core-talk

Navigate by Date:
Prev: Re: [Merge] ~epics-core/epics-base/+git/asLib:as-hostname into epics-base:7.0 Andrew Johnson via Core-talk
Next: Re: epicsThreadSleep and epicsThreadSleepQuantum Mark Rivers via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: [Merge] ~anj/epics-base/+git/base-3.15:vxworks-tz-support into epics-base:3.15 noreply--- via Core-talk
Next: Re: epicsThreadSleep and epicsThreadSleepQuantum Mark Rivers via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 22 Oct 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·