X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_task.c;h=4a78766e2828664b1687b09f0ea28a02ac987066;hp=14aa84c841d698d3a285de7370c80de369c7b56f;hb=00f49c8fb0aa38331360bdb85c32bcebe60dcdc3;hpb=73db30b2f9128c37dc7fa075793a8862814ce044 diff --git a/src/ao_task.c b/src/ao_task.c index 14aa84c8..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; } @@ -228,7 +231,7 @@ ao_wake_task(__xdata struct ao_task *task) } void -ao_exit(void) +ao_exit(void) __critical { uint8_t i; ao_num_tasks--;