EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: timer delay compensation
From: Eric Norum <[email protected]>
To: Andrew Johnson <[email protected]>
Cc: EPICS core-talk <[email protected]>
Date: Thu, 14 Jun 2012 16:21:02 -0700
On Jun 14, 2012, at 3:52 PM, Andrew Johnson wrote:
……...

Lets go with 0.999999999, chosen since we only represent time down to the
nanosecond anyway.

The units of the addition are 'ticks' so 9 9's is actually a fraction of a nanosecond (likely 1/50, 1/60 or 1/100).  
But even so the '1 extra tick' problem wouldn't show up until around 8 million ticks (10^9 ticks ~= 30 bits, 53 bit double mantissa) so 9 9's it is.


Here's the RTEMS implementation:
void
epicsThreadSleep (double seconds)
{
    rtems_status_code sc;
    rtems_interval delay;
    extern double rtemsTicksPerSecond_double;
   
    if (seconds <= 0.0) {
        delay = 0;
    }
    else {
        /*
         * Low-overhead approximation of ceil()
         */
        delay = seconds * rtemsTicksPerSecond_double + 0.999999999;
    }
    sc = rtems_task_wake_after (delay);
    if(sc != RTEMS_SUCCESSFUL)
        errlogPrintf("epicsThreadSleep: %s\n", rtems_status_text (sc));
}


-- 
Eric Norum
[email protected]


References:
timer delay compensation Hill, Jeff
Re: timer delay compensation Andrew Johnson

Navigate by Date:
Prev: Re: timer delay compensation Andrew Johnson
Next: Re: [Merge] lp:~epics-core/epics-base/thread-pool into lp:epics-base mdavidsaver
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: timer delay compensation Andrew Johnson
Next: [Merge] lp:~dirk.zimoch/epics-base/non-val-attributes into lp:epics-base/3.14 Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 26 Nov 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·