- Task notifications.
- Using task notifications as a light weight binary semaphore.
Task notifications are an efficient mechanism to allow tasks to interact with other tasks, and to synchronize with ISRs, without the need for a separate communication object. Using a task notification to send an event or data to a task is significantly faster than using a queue, semaphore or event group to perform an equivalent operation. These performance benefits come with some use case limitations:
- Task notifications can only be used when there is only one task that can be the recipient of the event.
- While a receiving task can wait for a notification in the Blocked state (so not consuming any CPU time), a sending task cannot wait in the Blocked state for a send to complete if the send cannot complete immediately.
When a task notification is used in place of a binary semaphore the receiving task's notification value is used in place of the binary semaphore's count value, and the ulTaskNotifyTake() (or ulTaskNotifyTakeIndexed()) API function is used in place of the semaphore's xSemaphoreTake() API function. The ulTaskNotifyTake() function's xClearOnExit parameter is set to pdTRUE so the count value is returned to zero each time the notification is taken - emulating a binary semaphore. Likewise the xTaskNotifyGive() (or xTaskNotifyGiveIndexed()) is used in place of the semaphore's xSemaphoreGive() function.
-
Complete all the TODOs in the
source/tutorials/tutorial_17/source/tutorial_17.c
file. -
Execute the following commands from the root of the repository to build:
rm -rf build mkdir build cd build cmake -B . -S ../source/ -DTUTORIAL=17 make
-
Execute the following command to run the binary:
./freertos_example
-
Understand the output.