-
Notifications
You must be signed in to change notification settings - Fork 245
Description
Describe the bug
There discrepancies between the expected first callback and the time the first callback actually occurs, for timers created via OS_TimerCreate(). This is with regards to the "start_time" parameter.
To Reproduce
The timer-test example program exposes this bug. It was never seen because on POSIX the difference is not substantial enough to cause failure, but on VxWorks it does fail.
General sequence is:
Create a timer via OS_TimerCreate()
Set the timer using OS_TimerSet() with start_time=2000000 (2 sec) and interval_time=400000 (400ms).
The time between the OS_TimerSet call and the first timer callback should be 2 seconds (within system timer tick tolerances) but it is approximately 2.4 seconds on POSIX. On VxWorks the difference is even more substantial, causing failure of the timer-test example program.
Expected behavior
The time between the OS_TimerSet call and the first timer callback should be equivalent to the start_time parameter from the OS_TimerSet call.
System observed on:
Ubuntu 18.04.2 LTS, 64 bit, using posix OSAL build
VxWorks 6.9 on MCP750, using vxworks OSAL build
Both running the "timer-test" example program.
Additional context
This appears to be limited to cases where the backward-compatible OS_TimerCreate API is used. In this case an implicit timebase object is created just to service the single timer. In this mode, there is an initial condition issue in the wait routine, and the first interval therefore is not correct.
If the timer callback is registered via OS_TimeBaseCreate() followed by OS_TimerAdd(), then it is OK.
Reporter Info
Joseph Hickey, Vantage Systems, Inc.