What is the correct signature of a FreeRTOS task function?
A FreeRTOS task function must return void and take a single void pointer parameter. Example:
void TaskName(void *pvParameters)
Click to reveal answer
beginner
Why does a FreeRTOS task function take a void pointer as a parameter?
The void pointer allows passing any type of data to the task when it starts, making the task flexible to receive different inputs.
Click to reveal answer
beginner
Can a FreeRTOS task function return a value?
No, a FreeRTOS task function must have a void return type because tasks run indefinitely or until deleted, and the scheduler does not expect a return value.
Click to reveal answer
intermediate
What happens if a FreeRTOS task function does not include an infinite loop?
If the task function returns (exits), the task is deleted automatically by the scheduler, which can cause unexpected behavior if not intended.
Click to reveal answer
beginner
Show an example of a minimal FreeRTOS task function signature and body.
void MyTask(void *pvParameters) {
for (;;) {
// Task code here
}
}
Click to reveal answer
What is the return type of a FreeRTOS task function?
Avoid
Bint
Cbool
Dchar*
✗ Incorrect
FreeRTOS task functions must return void because the scheduler does not expect any return value.
What parameter type does a FreeRTOS task function accept?
Achar
Bint
Cvoid*
Dfloat
✗ Incorrect
The task function accepts a void pointer to allow passing any type of data.
What happens if a FreeRTOS task function returns instead of looping forever?
AThe system crashes
BThe task restarts automatically
CNothing happens
DThe task is deleted
✗ Incorrect
If the task function returns, the task is deleted by the scheduler.
Which of these is a correct FreeRTOS task function signature?
Aint Task(void)
Bvoid Task(void *pvParameters)
Cvoid Task()
Dint Task(void *pvParameters)
✗ Incorrect
The correct signature is void return type with a void pointer parameter.
Why is the parameter of a FreeRTOS task function a void pointer?
ATo allow passing any type of data
BTo restrict data types
CBecause tasks cannot have parameters
DTo return data from the task
✗ Incorrect
A void pointer allows passing any type of data to the task.
Describe the required signature of a FreeRTOS task function and explain why it is designed that way.
Think about how tasks receive data and how the scheduler manages them.
You got /4 concepts.
Explain what happens if a FreeRTOS task function finishes execution and returns instead of looping forever.
Consider the lifecycle of a task in FreeRTOS.
You got /3 concepts.
Practice
(1/5)
1.
What is the correct signature for a FreeRTOS task function?
easy
A. int TaskName(int param)
B. void TaskName(void *pvParameters)
C. void TaskName()
D. void TaskName(int *param)
Solution
Step 1: Recall FreeRTOS task function signature
FreeRTOS tasks must have the signature with return type void and a single void pointer parameter.
Step 2: Match the signature with options
Only void TaskName(void *pvParameters) matches void TaskName(void *pvParameters) exactly.