diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-10-10 21:16:21 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-10-10 21:22:59 +0200 |
commit | c2ba3ad6604ef2e189d7e0a36d6911116e84d3ab (patch) | |
tree | 195bd9feba12c118a6b35fc5aa4710e681d757b2 /src/shared | |
parent | 5a045dad1c5adf17d9198b15d085c9425c1dae8e (diff) |
event: add timer accuracy/coalescing logic
In order to improve energy consumption we should minimize our wake-ups
when handling timers. Hence, for each timer take an accuracy value and
schedule the actual wake-up time somewhere between the specified time
and the specified timer plus the accuracy.
The specified time of timer event sources hence becomes the time the
handler is called the *earliest*, and the specified time plus the accuracy
the time by which it is called the *latest*, leaving the library the
freedom to schedule the wake-up somewhere inbetween.
If the accuracy is specified as 0 the default of 250ms will be used.
When scheduling timeouts we will now try to elapse them at the same
point within each second, across the entire system. We do this by using
a fixed perturbation value keyed off the boot id. If this point within a
second is not in the acceptable range, we try again with a fixed time
within each 250ms time step. If that doesn't work either, we wake up at
the last possible time.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/prioq.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/shared/prioq.c b/src/shared/prioq.c index 2d166360aa..537befc623 100644 --- a/src/shared/prioq.c +++ b/src/shared/prioq.c @@ -217,7 +217,8 @@ _pure_ static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) assert(q); if (idx) { - if (*idx > q->n_items) + if (*idx == PRIOQ_IDX_NULL || + *idx > q->n_items) return NULL; i = q->items + *idx; |