Task implementation and troubleshooting
This section presents several topics related to task implementation, and to troubleshooting task startup problems.
Task memory allocation
One of the things we glossed over previously was why a call to xTaskCreate()
can fail. That’s an excellent question – let’s find out!
One of the parameters for xTaskCreate()
defines the task’s stack size. But where does the RAM for this stack come from? There are two options – dynamic allocation of memory and static allocation of memory.
Dynamic allocation of memory is implemented with a heap. FreeRTOS contains several different heap implementations. FreeRTOS heaps will be explained later. For now, it is sufficient to assume a heap is available.
Static allocation of memory permanently reserves RAM for data, for the life of the program. Let’s see what each approach looks like.
Dynamically allocated tasks
Our example-program has two calls...