summaryrefslogtreecommitdiff
path: root/ao_task.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-04-25 14:43:23 -0700
committerKeith Packard <keithp@keithp.com>2009-04-25 14:43:23 -0700
commit7bc3d9962872850e7b420221cf689db16b4305cc (patch)
tree093d8daeca290f7bcd2c3aee374bb5df582b6048 /ao_task.c
parente45fce7f82d704d677f84c69b0e07588d109d780 (diff)
Place CPU in P0 state while idle
Diffstat (limited to 'ao_task.c')
-rw-r--r--ao_task.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/ao_task.c b/ao_task.c
index 81a71dda..b69f51ee 100644
--- a/ao_task.c
+++ b/ao_task.c
@@ -114,13 +114,23 @@ ao_yield(void) _naked
/* Find a task to run. If there isn't any runnable task,
* this loop will run forever, which is just fine
*/
- for (;;) {
- ++ao_cur_task_index;
- if (ao_cur_task_index == ao_num_tasks)
- ao_cur_task_index = 0;
- ao_cur_task = ao_tasks[ao_cur_task_index];
- if (ao_cur_task->wchan == NULL)
- break;
+ {
+ __pdata uint8_t ao_next_task_index = ao_cur_task_index;
+ for (;;) {
+ ++ao_next_task_index;
+ if (ao_next_task_index == ao_num_tasks)
+ ao_next_task_index = 0;
+
+ ao_cur_task = ao_tasks[ao_next_task_index];
+ if (ao_cur_task->wchan == NULL) {
+ ao_cur_task_index = ao_next_task_index;
+ break;
+ }
+
+ /* Enter lower power mode when there isn't anything to do */
+ if (ao_next_task_index == ao_cur_task_index)
+ PCON = PCON_IDLE;
+ }
}
{