0
0
FreeRTOSprogramming~10 mins

Time-slicing for equal priority tasks in FreeRTOS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create two tasks with equal priority in FreeRTOS.

FreeRTOS
xTaskCreate(task1, "Task1", 1000, NULL, [1], NULL);
Drag options to blanks, or click blank then click option'
A0
B1
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using different priority numbers for tasks that should share CPU time equally.
Confusing stack size with priority.
2fill in blank
medium

Complete the code to start the FreeRTOS scheduler after creating tasks.

FreeRTOS
vTaskStart[1]();
Drag options to blanks, or click blank then click option'
AStartScheduler
BScheduler
CStart
DRunScheduler
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names like vTaskStart or vTaskRun.
Forgetting to start the scheduler after creating tasks.
3fill in blank
hard

Fix the error in the task function to allow time-slicing by yielding the processor.

FreeRTOS
void task1(void *pvParameters) {
    for(;;) {
        // Task code here
        [1]();
    }
}
Drag options to blanks, or click blank then click option'
AvTaskDelay
BvTaskSuspend
CvTaskDelete
DtaskYIELD
Attempts:
3 left
💡 Hint
Common Mistakes
Using vTaskDelay without a delay time, which causes errors.
Using vTaskSuspend or vTaskDelete which stop the task instead of yielding.
4fill in blank
hard

Fill both blanks to create two tasks with equal priority and start the scheduler.

FreeRTOS
xTaskCreate(task1, "Task1", 1000, NULL, [1], NULL);
xTaskCreate(task2, "Task2", 1000, NULL, [2], NULL);
vTaskStartScheduler();
Drag options to blanks, or click blank then click option'
A2
B1
C3
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning different priorities to the tasks, which disables time-slicing.
Using zero priority which may cause unexpected behavior.
5fill in blank
hard

Fill all three blanks to create a task that yields, create two equal priority tasks, and start the scheduler.

FreeRTOS
void task1(void *pvParameters) {
    for(;;) {
        // Task code
        [1]();
    }
}
xTaskCreate(task1, "Task1", 1000, NULL, [2], NULL);
xTaskCreate(task2, "Task2", 1000, NULL, [3], NULL);
vTaskStartScheduler();
Drag options to blanks, or click blank then click option'
AvTaskDelay
BtaskYIELD
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using vTaskDelay without parameters inside the task.
Assigning different priorities to tasks.
Forgetting to start the scheduler.