forked from orocos-toolchain/rtt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consistently use a monotonic clock source for the gnulinux target
The absolute time returned by rtos_get_time_ns() or RTT::os::TimeService::getNSecs() was generated from a wall clock (time of day), which is not monotonic and can jump in certain cases, e.g. due to an NTP update. This time is used in several internal and public API functions to implement timers or to wait on a condition variable, mutex or semaphore with a timeout. In all these cases non-steady system time can have undesirable side effects, which are not expected in a Real-Time Toolkit. There have been several attempts to fix or at least mitigate that problem: - http://bugs.orocos.org/show_bug.cgi?id=735 - orocos-toolchain#129 - orocos-toolchain#138 This patch introduces some potentially breaking changes: - Use clock_gettime(CLOCK_MONOTONIC, ...) to implement rtos_get_time_ns() for the gnulinux target. This change has a major impact on all usages of that method, rtos_get_ticks() or the higher-level methods RTT::os::TimeService::getNSecs() and RTT::os::TimeService::getTicks(), whose return values cannot be interpreted as wall time anymore. - Consequently remove the rtos_get_time_monotonic-ns() function introduced in orocos-toolchain#138. - Drop RTT::os::Semaphore::waitUntil() and the underlying OS abstraction functions. The only usage within the RTT core was in RTT::os::Timer, which can easily be rewritten using condition variables. POSIX semaphores do not support waiting with an absolute timeout from the monotonic clock. - Added new OS abstraction functions for waiting on a mutex lock with a relative timeout. POSIX does not provide a pthread_mutexattr_setclock() method similar to pthread_condattr_setclock(). For that reason rtos_mutex_lock_until() and rtos_mutex_trylock_for() are currently falling back to CLOCK_REALTIME. Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
- Loading branch information
Showing
8 changed files
with
96 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.