[riot-notifications] [RIOT-OS/RIOT] xtimer: Fix backoff condition in _xtimer_set_absolute (#7628)

Joakim NohlgÄrd notifications at github.com
Sun Sep 24 10:35:04 CEST 2017


gebart commented on this pull request.



> @@ -176,7 +176,9 @@ int _xtimer_set_absolute(xtimer_t *timer, uint32_t target)
     DEBUG("timer_set_absolute(): now=%" PRIu32 " target=%" PRIu32 "\n", now, target);
 
     timer->next = NULL;
-    if ((target >= now) && ((target - XTIMER_BACKOFF) < now)) {
+    /* The (target - now) difference works across the long tick rollover, there
+     * is no need to check for (target > now) first. */
+    if ((target - now) < XTIMER_BACKOFF) {
         /* backoff */
         xtimer_spin_until(target + XTIMER_BACKOFF);

The reason for adding a backoff here is that there is a non-zero amount of time that has passed between the `_xtimer_now` call and the `xtimer_spin_until` call, so there is a risk that target is already in the past, which will make the system spin for a full lltimer cycle instead of just returning. This is not an ideal solution though, but I don't have any better ideas at the moment.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/7628#discussion_r140650547
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20170924/8ea502ab/attachment-0001.html>


More information about the notifications mailing list