Challenge - 5 Problems
FreeRTOS Task Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this FreeRTOS task function signature code?
Consider this FreeRTOS task function signature and its usage. What will be the output when the task runs?
FreeRTOS
void vTaskCode(void *pvParameters) {
int *p = (int *)pvParameters;
printf("Value: %d\n", *p);
}
int main() {
int x = 10;
vTaskCode(&x);
return 0;
}Attempts:
2 left
💡 Hint
Remember the task function takes a void pointer parameter which can be cast to any type.
✗ Incorrect
The task function receives a void pointer which is cast to int pointer. The value pointed to is printed correctly as 10.
❓ Predict Output
intermediate2:00remaining
What error occurs with this incorrect FreeRTOS task function signature?
What error will this code produce when compiled or run?
FreeRTOS
void vTaskCode(int pvParameters) { printf("Value: %d\n", pvParameters); } int main() { int x = 5; vTaskCode(x); return 0; }
Attempts:
2 left
💡 Hint
Check the parameter type expected by FreeRTOS task functions.
✗ Incorrect
Although the signature is not the standard FreeRTOS task signature, this code compiles and prints 5 because the function is called directly.
🧠 Conceptual
advanced2:00remaining
Which is the correct FreeRTOS task function signature?
Select the correct function signature for a FreeRTOS task function.
Attempts:
2 left
💡 Hint
FreeRTOS task functions always take a void pointer parameter and return void.
✗ Incorrect
FreeRTOS task functions must have the signature void function(void *pvParameters) to be compatible with the scheduler.
❓ Predict Output
advanced2:00remaining
What is the output of this FreeRTOS task function with pointer parameter?
What will this code print when the task function runs?
FreeRTOS
void vTaskCode(void *pvParameters) {
char *msg = (char *)pvParameters;
printf("Message: %s\n", msg);
}
int main() {
char message[] = "Hello FreeRTOS";
vTaskCode(message);
return 0;
}Attempts:
2 left
💡 Hint
Casting void pointer to char pointer is valid for string parameters.
✗ Incorrect
The void pointer is cast to char pointer correctly and prints the string.
🧠 Conceptual
expert2:00remaining
Why must FreeRTOS task functions have the signature void function(void *pvParameters)?
Choose the best explanation for why FreeRTOS task functions require this signature.
Attempts:
2 left
💡 Hint
Think about how the scheduler manages tasks and passes data.
✗ Incorrect
The scheduler calls task functions expecting void return and a void pointer parameter to pass any user data generically.