summaryrefslogtreecommitdiff
path: root/src/ao_task.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-12-19 15:31:36 -0800
committerKeith Packard <keithp@keithp.com>2009-12-19 15:31:36 -0800
commiteddb82390a0ecb07ef83c04861993842906b03ab (patch)
tree3986d81b2d7281ecb96e499d6ddfb17fcac210de /src/ao_task.c
parent598d168bd6552c3756e4b0267de44147eadab9f6 (diff)
Ensure that ao_alarm waits at least the specified time
Because the timer tick may happen soon, it's important to delay by another tick to ensure that we don't wake up early. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/ao_task.c')
-rw-r--r--src/ao_task.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ao_task.c b/src/ao_task.c
index 4664163d..4a78766e 100644
--- a/src/ao_task.c
+++ b/src/ao_task.c
@@ -217,7 +217,10 @@ ao_wakeup(__xdata void *wchan)
void
ao_alarm(uint16_t delay)
{
- if (!(ao_cur_task->alarm = ao_time() + delay))
+ /* Make sure we sleep *at least* delay ticks, which means adding
+ * one to account for the fact that we may be close to the next tick
+ */
+ if (!(ao_cur_task->alarm = ao_time() + delay + 1))
ao_cur_task->alarm = 1;
}