Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a task with priority 2.
FreeRTOS
xTaskCreate(taskFunction, "Task1", 1000, NULL, [1], NULL);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as priority which is the lowest priority.
Confusing stack size with priority.
✗ Incorrect
The priority parameter sets the task priority. Here, 2 is the correct priority.
2fill in blank
mediumComplete the code to start the FreeRTOS scheduler.
FreeRTOS
int main(void) {
// Setup code
[1]();
while(1) {}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling
xTaskCreate instead of starting the scheduler.Forgetting to start the scheduler.
✗ Incorrect
vTaskStartScheduler() starts the FreeRTOS scheduler to run tasks based on priority.
3fill in blank
hardFix the error in the task priority assignment.
FreeRTOS
xTaskCreate(taskFunction, "Task2", 1000, NULL, [1], NULL);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a negative priority.
Using a priority equal to
configMAX_PRIORITIES.✗ Incorrect
Task priority must be less than configMAX_PRIORITIES. The highest valid priority is configMAX_PRIORITIES - 1.
4fill in blank
hardFill both blanks to create a task and set its priority to 3.
FreeRTOS
xTaskCreate([1], "Task3", 1000, NULL, [2], NULL);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up function names.
Using wrong priority values.
✗ Incorrect
The task function is taskFunction3 and the priority is 3 as requested.
5fill in blank
hardFill all three blanks to create a task with priority 4 and start the scheduler.
FreeRTOS
xTaskCreate([1], "Task4", 1000, NULL, [2], NULL); [3]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not starting the scheduler after creating the task.
Using incorrect function names or priorities.
✗ Incorrect
The task function is taskFunction4, priority is 4, and the scheduler is started with vTaskStartScheduler().