status = clock_abstime2ticks(CLOCK_REALTIME, abstime, &ticks);
Shouldn't there be an #ifdef that selects CLOCK_MONOTONIC when it's configured?
Has clock_abstime2ticks() been tested using CLOCK_MONOTONIC?
-Bob
So, no clock_abstime2ticks() has never been tested with CLOCK_MONOTONIC and nor do I suspect that it would work.
It seems to me that running sem_timedwait() using CLOCK_REALTIME would be very problematic.
Embedded systems often have to slave their "system time" to an external entity, such as network time or in our case GPS time.
Our chips oscillator will drift with respect to the external time base, so we resync our "system time" periodically. The tail of these corrections goes over a hundreds of milliseconds. If the local "system time" falls behind the external reference, say by about 150 ms, then when the time is resynchronized CLOCK_REALTIME will jump ahead by those 150 ms and any outstanding sem_timedwait() actions would be impacted.
We use CLOCK_MONOTONIC for time that must be monotonic and CLOCK_REALTIME for time that must be in sync with our external time base.
Are we using the wrong mechanism for time synchronization?
No, but per the POSIX standard, the *absolute time* provided to sem_timedwait() must be based on CLOCK_REALTIME. That is a POSIX requirement and you must conform to it if you wish to use a POSIX operating system.
I will need to use time resyncronization on my next project and I want to understand better the issue you are facing. Is your problem similar to it: https://stackoverflow.com/questions/29153310/how-would-i-cope-with-changes-to-the-system-time-while-doing-sem-timedwait
--
You received this message because you are subscribed to the Google Groups "NuttX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nuttx+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to nuttx+unsubscribe@googlegroups.com.