EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026>  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026> 
<== Date ==> <== Thread ==>

Subject: Re: Short EPICS event waits under RTEMS
From: "Johnson, Andrew N. via Tech-talk" <tech-talk at aps.anl.gov>
To: "Rivers, Mark L." <rivers at cars.uchicago.edu>, Alex Wells <alex.wells at diamond.ac.uk>
Cc: Jack Harper STFC UKRI via Tech-talk <tech-talk at aps.anl.gov>
Date: Fri, 28 Aug 2026 15:15:01 +0000
Hi Alex,

Mark is probably referring to this commit which appeared in 7.0.10, but it doesn't affect IOCs running on VxWorks or RTEMS.

Why aren’t you running your clock at 1KHz on RTEMS to match VxWorks?

This is a long-known issue with the EPICS timers on our embedded OSs, which both use ticks for their timer calls. It could be fixed by having the EPICS code check the nanosecond clock and retry the OS operation when that returns early with a timeout, but nobody has taken up and implemented that change. It would be a good Codeathon project for someone working with an embedded OS.

- Andrew

-- 
Complexity comes for free, Simplicity you have to work for.


On 8/28/26, 9:59 AM, "Tech-talk" <tech-talk-bounces at aps.anl.gov> wrote:

What version of base are you using? There have been recent changes.

Mark

Sent from my iPhone

On Aug 28, 2026, at 9:49 AM, Wells, Alex (DLSLtd,RAL,TEC) via Tech-talk <tech-talk at aps.anl.gov> wrote:


Hi TechTalk,

I'm having some difficulties when migrating from VxWorks to RTEMS around how timeouts seem to be handled for very short periods. 

Under VxWorks, I set a clock speed of 1000, i.e. 1kHz. I then had some events that had a timeout of 10 "ticks", so a wall time of 10ms. This event was triggered when the associated hardware finishes its read/write cycle - it would send an interrupt, and in the handler I signal the waited-on event. Interrupts were also often turned off, to save CPU time, so the events would just timeout but this caused no issues as the hardware read/write would complete inside the 10ms. 

Under RTEMS, I have a different clock speed of 100Hz. I set the same timeout of 10ms (0.01s). I also have interrupts disabled so that the Event will never be signalled. I see different behaviour - some of my reads/writes now report errors, as though they are attempting to execute too fast and not actually waiting the 10ms for the hardware to act.

This seems to be backed up by using EPICS' nanosecond timing functions. Using "epicsTimeGetCurrent" before and after the "epicsEventWaitWithTimeout" function, and then calling "epicsTimeDiffInNS" gives a mean and median duration of ~5ms between the before and after times. I suspect this means the EPICS Event Wait function is not actually waiting at all.

Is this somehow to do with the fact I'm trying to wait for exactly one tick? Or is there some other explanation for why my wait time is not being reached?

Thank you for any help,
Alex Wells





This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom.

Replies:
Re: Short EPICS event waits under RTEMS Joel Sherrill via Tech-talk
Re: Short EPICS event waits under RTEMS Wells, Alex (DLSLtd,RAL,TEC) via Tech-talk
References:
Short EPICS event waits under RTEMS Wells, Alex (DLSLtd,RAL,TEC) via Tech-talk
Re: Short EPICS event waits under RTEMS Mark Rivers via Tech-talk

Navigate by Date:
Prev: RE: Short EPICS event waits under RTEMS Engbretson, Mark S. via Tech-talk
Next: Re: Short EPICS event waits under RTEMS Joel Sherrill via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026> 
Navigate by Thread:
Prev: RE: Short EPICS event waits under RTEMS Engbretson, Mark S. via Tech-talk
Next: Re: Short EPICS event waits under RTEMS Joel Sherrill via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026> 
ANJ, 28 Aug 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·