xTaskCreate Questions

What is the difference between and different use cases for xTaskCreate, xTaskCreateStatic and xTaskCreateRestricted?

Many thanks in advance!

xTaskCreate gets the memory for the Task Control Block from the heap.
xTaskCreateStatic is given the memory blocks to create the task.

With the static version, you can control where that memory is taken from (so you can put the stack in faster memory for instance), and lets you know at link time that you have your memory properly allocated, but isn’t as good if you need to dynamically create tasks (which, to be honest, isn’t normally needed). The dynamic version might let you dymanically create and destroy tasks using less memory.

The xTaskCreateRestricted is only available on processors with a Memory Protection Unit, and lets you create tasks which are tightly restricted in what they can access/write to.

1 Like

Here are the respective API doc pages:
xTaskCreateRestricted() (wording of this one is a little eccentric)

1 Like