I have question about scheduler when all thread in sleep

when all thread in sleep except idle thread

then idle task call lpm_set and OS go to low power mode

in this condition, when scheduler wake up from low power mode and restart schedule?

and how to know scheduler when wake up itself?

Hey,

in this condition, when scheduler wake up from low power mode and restart schedule?

and how to know scheduler when wake up itself?

The system gets woken up by external interrupts, e.g., a timer, gpio-pin. That powers up the MCU and executes the corresponding interrupt handler. Should that handler do something that wakes a thread (calling thread_wakeup(), release a mutex, send a message or set a thread_flag), that triggers the scheduler and then leads to a context switch into the thread(s).

The scheduler never wakes up itself.

Kaspar

In this thinking concept of achieving some repetitive task, you should perhaps configure a hw timer to create a stream of interrupts.

Said interrupts then individually wake up mcu, go via irq handler and start processing that then yields, allowing the scheduler to put mcu into sleep mode. This is then repeated.

Most normal modern mcus support configuring a timer for this purpose, the interrupts can come from an external source or mcu internal peripherals such as adc can act as interrupt stream generator.

- t

Dear Teemu, What you are describing sounds like the xtimer subsystem in RIOT. It uses a hardware timer to schedule tasks in the future. See examples/xtimer_periodic_wakeup in the RIOT sources for an example on how to achieve periodic scheduling for your task.

Also note that the function xtimer_usleep_until used in the example may be renamed xtimer_periodic_wakeup in a near future, see 1. The functionality will remain the same and the example will be updated at the same time the rename happens.

Best regards, Joakim