Avoid early expiration of timers on !RTOS

This commit is contained in:
Michael Davidsaver
2022-09-29 17:21:44 -07:00
parent 491d532170
commit 01360b2a69
4 changed files with 30 additions and 1 deletions

View File

@@ -65,7 +65,11 @@ 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 TIMER_QUANTUM_BIAS
- ( this->queue.notify.quantum () / 2.0 )
#endif
;
bool reschedualNeeded = false;
if ( this->curState == stateActive ) {

View File

@@ -35,6 +35,16 @@
# define debugPrintf(ARGSINPAREN)
#endif
/* For historical reasons, round down expiration time on vxWorks and RTEMS.
* Targets with a fixed timer period.
* This biasing down by half a period allows timers which expire on every tick.
* Otherwise, the fastest timer is 2x the tick period.
* This results in timers expiring one period earlier than requested.
*/
#if defined(vxWorks) || defined(__rtems__)
# define TIMER_QUANTUM_BIAS 1
#endif
template < class T > class epicsGuard;
class timer : public epicsTimer, public tsDLNode < timer > {

View File

@@ -10,6 +10,9 @@
TOP = ../../..
include $(TOP)/configure/CONFIG
# allow tests to peek at private headers
USR_CPPFLAGS += -I$(TOP)/modules/libcom/src
PROD_LIBS += Com
PROD_SYS_LIBS_WIN32 += ws2_32 advapi32 user32
PROD_SYS_LIBS_solaris += socket nsl