diff --git a/PowerManagement.cpp b/PowerManagement.cpp index e6540d8..6f173e5 100644 --- a/PowerManagement.cpp +++ b/PowerManagement.cpp @@ -65,14 +65,18 @@ int PowerManagement(int pid, unsigned int signal) case POWER_STATE_IDLE: if (accumulator > SLEEP_TIMEOUT) { - sleep(); + if (Kernel_count_running_tasks() == 1) + { + sleep(); + } + else + { + Kernel_signal(SIGNAL_STOP); + } } break; } - // TODO: On sleep, signal "STOP" to all tasks and reschedule ourselves more frequently - // Wait until Kernel_count_running == 1, then put chip to sleep - return 0; }