On 6/11/19 6:57 AM, Mark Rivers via Core-talk wrote:
>> If we want to sleep for a minimum amount of time we might want to call nanosleep(0) instead.
>
> But that will not work on Windows or vxWorks.
>
> Mark
>
>
> -----Original Message-----
> From: Konrad, Martin <[email protected]>
> Sent: Tuesday, June 11, 2019 8:49 AM
> To: Mark Rivers <[email protected]>; [email protected]
> Subject: Re: epicsThreadSleep and epicsThreadSleepQuantum
>
> Hi,
>> I started a tech-talk thread on this topic 11 years ago:
>>
>> https://epics.anl.gov/tech-talk/2008/msg00987.php
> Thanks Mark, I wasn't aware of this thread. I'm not aware of any way to detect the sleep quantum reliably on modern machines either. The fact that epicsThreadSleepQuantum() only works correctly on old machines without high resolution timers suggests that we should avoid using it. I think it would make sense to
I'll second this. Minimum sleep time is not a meaningful concept for a modern general purpose OS.
https://en.wikipedia.org/wiki/Tickless_kernel
All the usages of sleep(0) I've seen have been shortcuts to avoid using real synchronization primitives.
This is something I would discourage.
> a) Add a warning to the App Dev Guide.
> b) Consider marking epicsThreadSleepQuantum(), timerQueueActive::quantum(), and fdManager::quantum() as deprecated.
I'd be fine with this, provided all internal usages can be removed.
> c) Remove the "(ppsl->period < 2 * quantum)" part of the test in [1].
There is also a usage in timer::privateStart() to bias expiration time.
I wonder if this tweak is still relevant?
> this->exp = expire - ( this->queue.notify.quantum () / 2.0 );
https://github.com/epics-base/epics-base/blob/655c5bed925137619d4a538f7893400b38c7c907/modules/libcom/src/timer/timer.cpp#L69
originally introduced by:
https://github.com/epics-base/epics-base/commit/0792aebf952dbc4f7e7291e6175c27b72a80c338
The remaining usage I find in Base, outside of test code, is in various epicsThreadOnce()
implementations which spin to avoid coupling, or copying, the internals of osdEvent.c into osdThread.c.
> If we want to sleep for a minimum amount of time we might want to call
> nanosleep(0) instead. If I'm understanding the man page correctly this should result at least in a context switch.
Maybe add a dedicated call?
> /* Ensure your epicsThread is fresh and ready to start the day */
> void epicsSnooze();
- Replies:
- Re: epicsThreadSleep and epicsThreadSleepQuantum Mark Rivers via Core-talk
- Re: epicsThreadSleep and epicsThreadSleepQuantum Johnson, Andrew N. via Core-talk
- References:
- epicsThreadSleep and epicsThreadSleepQuantum Konrad, Martin via Core-talk
- Re: epicsThreadSleep and epicsThreadSleepQuantum Konrad, Martin via Core-talk
- RE: epicsThreadSleep and epicsThreadSleepQuantum Mark Rivers via Core-talk
- Navigate by Date:
- Prev:
Re: EPICS 7 PVA for Java Kasemir, Kay 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
<2019>
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: epicsThreadSleep and epicsThreadSleepQuantum Mark Rivers 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
<2019>
2020
2021
2022
2023
2024
|