Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #271: Correct interval time computations #277

Merged
merged 1 commit into from
Nov 7, 2019

Conversation

jphickey
Copy link
Contributor

Describe the contribution
Fixes issue #271, corrects the time intervals returned by the sigwait() routines for all three operating systems (POSIX, RTEMS, VxWorks).

Testing performed
Testing is focused on the operation of the timer-test example program and variations thereof.
Verified that all callbacks from all timers correlate with the configured "start_time" and "interval_time" parameters passed to the OS_TimerSet() configuration.

Verified CFE still boots and runs OK. (stops FLYWHEEL as normal based on 1Hz tick)

Expected behavior changes
No changes to applications/CFE.

The timer-test example program now runs and passes consistently on all platforms.

System(s) tested on:
Ubuntu 18.04.2 LTS 64 bit (simulation)
RTEMS 4.11 pc686 BSP running in QEMU
MPC750 VxWorks 6.9

Contributor Info
Joseph Hickey, Vantage Systems, Inc.

In VxWorks, the sigwait routine was not handling the actual time of
the first interval, which basically meant that the start_time was
elapsed twice before the first callback was generated.

This exposed a few other small but significant details regarding
how the intervals were dealt with across all operating systems.

For VxWorks and RTEMS, where the timer interval is rounded up to
an integer number of ticks, compute the actual interval time and
write a debug message in case it is different than the intended
value.  This makes it more obvious to the user that some
application/bsp changes might be necessary to get accurate timing.

For all operating systems, the "reset" flag needs to be sampled
AFTER the sigwait returns, not before it.  This flag gets set when
the OS_TimeBaseSet() API is called.

Removes an unused POSIX delay routine that was intended to support
use of clock_nanosleep() in place of the timer signal.  This mode
was never usable because OS_TimerCreate always allocates a signal and
fails if it cannot do so.  This code caused problems/incompatibilities
for the sigwait model which IS used, so it needed to be removed.
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the posix implementation, it's easier to follow. Any need in posix/linux to check for a timer interval that is different due to the tick rate (like RTEMS and vxWorks?)

I like the OS_DEBUG warnings that tell the user that the interval may be different.

In vxWorks was the posix timer API used so it could be similar to the posix code? Does the vxWorks API offer any features that the posix does not?

@jphickey
Copy link
Contributor Author

Any need in posix/linux to check for a timer interval that is different due to the tick rate (like RTEMS and vxWorks?)

On all my testing on various Linux/Glibc implementations, the timers have always worked correctly. That is, for any interval you specify, the implementation generates a signal at that interval, regardless of the system timer tick period. I haven't dug through the Glibc implementation, but it seems they are implementing whatever special sauce is needed to obtain the specific interval that was requested. I guess that's one of the benefits of using a full-fat C library instead of a trimmed-down one.

In vxWorks was the posix timer API used so it could be similar to the posix code? Does the vxWorks API offer any features that the posix does not?

Does VxWorks offer a better timer API than the posix(-ish) API that is being used here? This timer setup code was lifted from the vxworks6 OSAL and the same API was used there.

Honestly, I was surprised to see such a blatant difference between the requested interval and the actual provided interval, particularly because the requested interval was an exact multiple of timer ticks, yet timer_settime still added an extra tick to it, so it was basically just wrong at that point. It strikes me as a bug in the implementation.

Reading back the interval with timer_gettime is basically just a workaround for this bug, but should work fine on platforms that work correctly too.

@skliper
Copy link
Contributor

skliper commented Oct 31, 2019

CCB 20191030 - Code reviewed and approved

@skliper skliper added the CCB:Approved Indicates code review and approval by community CCB label Oct 31, 2019
skliper added a commit that referenced this pull request Oct 31, 2019
Fixes #271 #272 #273 #274
Code reviewed and approved at 20191030 CCB
@skliper skliper changed the base branch from master to ic-20191030 November 7, 2019 21:07
@skliper skliper merged commit 1f450b2 into ic-20191030 Nov 7, 2019
@skliper skliper deleted the fix-271-timer-intervals branch November 7, 2019 21:17
@skliper skliper added this to the 5.1.0 milestone Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants