0
0
FreeRTOSprogramming~10 mins

Task pooling for dynamic workloads 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 a task pool with FreeRTOS.

FreeRTOS
xTaskCreate([1], "Task1", 1000, NULL, 1, NULL);
Drag options to blanks, or click blank then click option'
AvTaskFunction
BvTaskDelete
CxQueueCreate
DxSemaphoreCreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using xQueueCreate instead of a task function.
Passing NULL as the task function.
Confusing task creation with semaphore or queue creation.
2fill in blank
medium

Complete the code to initialize a queue for task communication.

FreeRTOS
QueueHandle_t xQueue = [1](10, sizeof(int));
Drag options to blanks, or click blank then click option'
AxTaskCreate
BxSemaphoreCreateBinary
CxQueueCreate
DvTaskDelay
Attempts:
3 left
💡 Hint
Common Mistakes
Using xTaskCreate instead of xQueueCreate.
Using semaphore creation functions instead of queue creation.
Confusing queue creation with task delay.
3fill in blank
hard

Fix the error in the task pool code by completing the missing function call.

FreeRTOS
if (xTaskCreate(vTaskFunction, "Task", 1000, NULL, 1, &[1]) != pdPASS) {
    // Handle error
}
Drag options to blanks, or click blank then click option'
AxQueue
BxTimer
CxSemaphore
DxTaskHandle
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a queue or semaphore handle instead of a task handle.
Passing NULL when a handle pointer is needed.
Confusing timer handles with task handles.
4fill in blank
hard

Fill both blanks to create a task pool that dynamically handles workload.

FreeRTOS
for (int i = 0; i < [1]; i++) {
    xTaskCreate(vTaskFunction, "Task", 1000, NULL, [2], NULL);
}
Drag options to blanks, or click blank then click option'
A5
B1
C10
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero tasks or zero priority which disables tasks.
Using too few tasks to handle workload.
Using priority zero which is invalid.
5fill in blank
hard

Fill all three blanks to implement a task pool that processes data from a queue.

FreeRTOS
void vTaskFunction(void *pvParameters) {
    int data;
    while (1) {
        if (xQueueReceive([1], &data, [2]) == pdPASS) {
            processData(data);
        }
        vTaskDelay([3]);
    }
}
Drag options to blanks, or click blank then click option'
AxQueue
BportMAX_DELAY
C100 / portTICK_PERIOD_MS
DNULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using NULL instead of the queue handle.
Using zero timeout instead of portMAX_DELAY.
Using zero delay which causes tight looping.