From b49c751749dcd3e78991463c098f8d916f52179d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 24 Oct 2012 23:50:55 -0700 Subject: 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 --- src/core/ao_task.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/core/ao_task.h') 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 +#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 -- cgit v1.2.3