summaryrefslogtreecommitdiff
path: root/src/core/ao_task.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ao_task.h')
-rw-r--r--src/core/ao_task.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/core/ao_task.h b/src/core/ao_task.h
index 18edd866..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,14 +28,26 @@ 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;
+ uint32_t yields;
+ uint16_t start;
+ uint16_t max_run;
+#endif
};
-extern __xdata struct ao_task *__data ao_cur_task;
-
#define AO_NUM_TASKS 16 /* maximum number of tasks */
#define AO_NO_TASK 0 /* no task id */
+extern __xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS];
+extern __data uint8_t ao_num_tasks;
+extern __xdata struct ao_task *__data ao_cur_task;
+
/*
ao_task.c
*/
@@ -65,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);
@@ -77,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