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

Sebastian Meiling notifications at github.com
Sat Sep 23 20:32:56 CEST 2017

smlng 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);

Side question, which bothered me for some time: why add `XTIMER_BACKOFF` here (again?). Assuming `XTIMER_BACKOFF` is `50us` (default for many boards), and I use something like `xtimer_usleep(40)` the result is  that my apps actually sleep `90us` right? Though its more likely that the target time of `40us` ahead has already (or nearly) passed by the time this call gets here, anyway, but still this seems wrong to do here, or not?

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20170923/eaaeaedb/attachment-0001.html>

More information about the notifications mailing list