+void
+ao_alarm(uint16_t 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;
+}
+
+void
+ao_exit(void) __critical
+{
+ uint8_t i;
+ ao_num_tasks--;
+ for (i = ao_cur_task_index; i < ao_num_tasks; i++)
+ ao_tasks[i] = ao_tasks[i+1];
+ ao_cur_task_index = AO_NO_TASK_INDEX;
+ ao_yield();
+ /* we'll never get back here */
+}
+