tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
etl::experimental::freertos::this_task Namespace Reference

Functions

auto sleep_for (etl::uint32_t ticks) -> void
 Delay a task for a given number of ticks. The actual time that the task remains blocked depends on the tick rate.
 
auto sleep_until (etl::uint32_t &prev, etl::uint32_t increment) -> void
 Delay a task until a specified time. This function can be used by periodic tasks to ensure a constant execution frequency.
 
auto yield () -> void
 Request a context switch to another task.
 

Function Documentation

◆ sleep_for()

auto sleep_for ( etl::uint32_t ticks) -> void
inline

Delay a task for a given number of ticks. The actual time that the task remains blocked depends on the tick rate.

sleep_for() specifies a time at which the task wishes to unblock relative to the time at which sleep_for() is called. For example, specifying a block period of 100 ticks will cause the task to unblock 100 ticks after sleep_for() is called. sleep_for() does not therefore provide a good method of controlling the frequency of a periodic task as the path taken through the code, as well as other task and interrupt activity, will effect the frequency at which sleep_for() gets called and therefore the time at which the task next executes. See sleep_until() for an alternative API function designed to facilitate fixed frequency execution. It does this by specifying an absolute time (rather than a relative time) at which the calling task should unblock.

https://www.freertos.org/a00127.html

◆ sleep_until()

auto sleep_until ( etl::uint32_t & prev,
etl::uint32_t increment ) -> void
inline

Delay a task until a specified time. This function can be used by periodic tasks to ensure a constant execution frequency.

This function differs from sleep_for() in one important aspect: sleep_for() specifies a time at which the task wishes to unblock relative to the time at which sleep_for() is called, whereas sleep_until() specifies an absolute time at which the task wishes to unblock. sleep_for() will cause a task to block for the specified number of ticks from the time sleep_for() is called. It is therefore difficult to use sleep_for() by itself to generate a fixed execution frequency as the time between a task unblocking following a call to sleep_for() and that task next calling sleep_for() may not be fixed [the task may take a different path though the code between calls, or may get interrupted or preempted a different number of times each time it executes].

https://www.freertos.org/vtaskdelayuntil.html

◆ yield()

auto yield ( ) -> void
inline

Request a context switch to another task.

However, if there are no other tasks at a higher or equal priority to the task that calls yield() then the RTOS scheduler will simply select the task that called yield() to run again.

If configUSE_PREEMPTION is set to 1 then the RTOS scheduler will always be running the highest priority task that is able to run, so calling yield() will never result in a switch to a higher priority task.

https://www.freertos.org/a00020.html#taskYIELD