diff options
author | Keith Packard <keithp@keithp.com> | 2009-10-16 12:59:53 +0900 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-10-16 12:59:53 +0900 |
commit | b657aa209b9ea3b3efd33a940283b3ba60a169af (patch) | |
tree | b1803da45a1413a3758965fedaa554aac636a9dd /src/ao_task.c | |
parent | d709a0688eff84e25e24d755850ef045d6b0c3de (diff) |
Add ao_wake_task and ao_exit
ao_wake_task signals a specific task to wake up.
ao_exit terminates the current task.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/ao_task.c')
-rw-r--r-- | src/ao_task.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/ao_task.c b/src/ao_task.c index 12b73943..136444b0 100644 --- a/src/ao_task.c +++ b/src/ao_task.c @@ -93,7 +93,9 @@ ao_yield(void) _naked push _bp _endasm; - if (ao_cur_task_index != AO_NO_TASK_INDEX) + if (ao_cur_task_index == AO_NO_TASK_INDEX) + ao_cur_task_index = ao_num_tasks-1; + else { uint8_t stack_len; __data uint8_t *stack_ptr; @@ -199,6 +201,24 @@ ao_wakeup(__xdata void *wchan) } void +ao_wake_task(__xdata struct ao_task *task) +{ + task->wchan = NULL; +} + +void +ao_exit(void) +{ + 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 */ +} + +void ao_task_info(void) { uint8_t i; |