Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a task and store its handle.
FreeRTOS
TaskHandle_t [1] = NULL; xTaskCreate(taskFunction, "Task1", 1000, NULL, 1, &handle);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not matching the one passed to xTaskCreate.
Not declaring the handle variable before use.
✗ Incorrect
The variable 'handle' is used to store the task handle when creating a task.
2fill in blank
mediumComplete the code to delete a task using its handle.
FreeRTOS
vTaskDelete([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NULL to vTaskDelete deletes the current task, not the target task.
Using an undefined variable.
✗ Incorrect
To delete a specific task, pass its handle to vTaskDelete.
3fill in blank
hardFix the error in the code to suspend a task using its handle.
FreeRTOS
vTaskSuspend([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NULL instead of the task handle.
Using a different variable name than the one storing the handle.
✗ Incorrect
The correct handle variable 'handle' must be passed to vTaskSuspend to suspend the task.
4fill in blank
hardFill both blanks to resume a suspended task using its handle and check if the handle is valid.
FreeRTOS
if ([1] != NULL) { vTaskResume([2]); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables for the check and resume call.
Not checking if the handle is NULL before resuming.
✗ Incorrect
Check if 'handle' is not NULL before resuming the task using the same handle.
5fill in blank
hardFill all three blanks to create a task, store its handle, and then delete it.
FreeRTOS
TaskHandle_t [1] = NULL; xTaskCreate(taskFunction, "Task2", 1000, NULL, 1, &[2]); vTaskDelete([3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for declaration, creation, and deletion.
Not passing the address of the handle variable to xTaskCreate.
✗ Incorrect
Use the same variable 'handle2' to declare, pass to xTaskCreate, and delete the task.