diff options
author | Keith Packard <keithp@keithp.com> | 2012-10-24 23:50:55 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-10-25 00:07:14 -0700 |
commit | b49c751749dcd3e78991463c098f8d916f52179d (patch) | |
tree | edb44fa67b8458b4bcb7928d122ffcf291b00107 /src/core/ao_task.h | |
parent | 4b13d3c659240e5a8347b1ba7ab0bf1d8355eba3 (diff) |
altos: Add task queues.
This replaces the array-based scheduler with a queue-based one
instead. It should have the same basic scheduling semantics, but it
walks shorter lists for each operation, making it much more efficient
when the system has a lot of tasks.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_task.h')
-rw-r--r-- | src/core/ao_task.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/ao_task.h b/src/core/ao_task.h index 4319d632..b3f152a0 100644 --- a/src/core/ao_task.h +++ b/src/core/ao_task.h @@ -17,6 +17,9 @@ #ifndef _AO_TASK_H_ #define _AO_TASK_H_ +#if HAS_TASK_QUEUE +#include <ao_list.h> +#endif /* An AltOS task */ struct ao_task { @@ -25,6 +28,10 @@ struct ao_task { ao_arch_task_members /* any architecture-specific fields */ uint8_t task_id; /* unique id */ __code char *name; /* task name */ +#if HAS_TASK_QUEUE + struct ao_list queue; + struct ao_list alarm_queue; +#endif uint8_t stack[AO_STACK_SIZE]; /* saved stack */ #if HAS_SAMPLE_PROFILE uint32_t ticks; @@ -39,7 +46,6 @@ struct ao_task { extern __xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS]; extern __data uint8_t ao_num_tasks; -extern __data uint8_t ao_cur_task_index; extern __xdata struct ao_task *__data ao_cur_task; /* @@ -74,6 +80,12 @@ ao_yield(void) ao_arch_naked_declare; void ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant; +#if HAS_TASK_QUEUE +/* Called on timer interrupt to check alarms */ +void +ao_task_check_alarm(uint16_t tick); +#endif + /* Terminate the current task */ void ao_exit(void); @@ -86,4 +98,11 @@ ao_task_info(void); void ao_start_scheduler(void); +#if HAS_TASK_QUEUE +void +ao_task_init(void); +#else +#define ao_task_init() +#endif + #endif |