0
0
FreeRTOSprogramming~20 mins

Task function signature in FreeRTOS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FreeRTOS Task Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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;
}
ARuntime error due to invalid pointer
BValue: 0
CCompilation error due to wrong function signature
DValue: 10
Attempts:
2 left
💡 Hint
Remember the task function takes a void pointer parameter which can be cast to any type.
Predict Output
intermediate
2: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;
}
ACompilation error due to wrong parameter type
BPrints: Value: 5
CRuntime error due to invalid pointer
DNo output
Attempts:
2 left
💡 Hint
Check the parameter type expected by FreeRTOS task functions.
🧠 Conceptual
advanced
2:00remaining
Which is the correct FreeRTOS task function signature?
Select the correct function signature for a FreeRTOS task function.
Avoid TaskFunction()
Bint TaskFunction(int pvParameters)
Cvoid TaskFunction(void *pvParameters)
Dvoid TaskFunction(int *pvParameters)
Attempts:
2 left
💡 Hint
FreeRTOS task functions always take a void pointer parameter and return void.
Predict Output
advanced
2: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;
}
AMessage: Hello FreeRTOS
BCompilation error due to wrong cast
CMessage: (null)
DRuntime error due to invalid pointer
Attempts:
2 left
💡 Hint
Casting void pointer to char pointer is valid for string parameters.
🧠 Conceptual
expert
2: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.
ABecause the scheduler expects a function returning void and taking a generic pointer to pass any data.
BBecause void return type allows returning task status codes to the scheduler.
CBecause the parameter must always be an integer representing task ID.
DBecause FreeRTOS tasks cannot accept any parameters.
Attempts:
2 left
💡 Hint
Think about how the scheduler manages tasks and passes data.