0
0
FreeRTOSprogramming~10 mins

Resource manager task pattern 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 FreeRTOS task that manages a resource.

FreeRTOS
xTaskCreate([1], "ResourceManager", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
Drag options to blanks, or click blank then click option'
AvTaskDelete
BvTaskStartScheduler
CxQueueCreate
DResourceManagerTask
Attempts:
3 left
💡 Hint
Common Mistakes
Using scheduler or queue functions instead of the task function name.
Passing NULL instead of the task function.
2fill in blank
medium

Complete the code to wait for a resource request in the resource manager task.

FreeRTOS
if (xQueueReceive(resourceQueue, &request, [1]) == pdPASS) {
    // Process request
}
Drag options to blanks, or click blank then click option'
A0
BpdFALSE
CportMAX_DELAY
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 which causes no wait and immediate return.
Using a small number which causes timeout.
3fill in blank
hard

Fix the error in the resource manager task to properly notify the requester after processing.

FreeRTOS
xTaskNotifyGive([1]);
Drag options to blanks, or click blank then click option'
ArequestingTaskHandle
BNULL
CresourceQueue
DResourceManagerTaskHandle
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NULL or the queue handle instead of the task handle.
Not notifying the requester task.
4fill in blank
hard

Fill both blanks to correctly send a resource request and wait for notification.

FreeRTOS
xQueueSend(resourceQueue, &request, [1]);
ulTaskNotifyTake([2], portMAX_DELAY);
Drag options to blanks, or click blank then click option'
AportMAX_DELAY
BpdTRUE
CpdFALSE
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using portMAX_DELAY for queue send block time which can block indefinitely.
Using pdFALSE for ulTaskNotifyTake which does not clear the notification.
5fill in blank
hard

Fill the blanks to implement a resource manager task loop that receives requests, processes them, and notifies the requester.

FreeRTOS
void ResourceManagerTask(void *pvParameters) {
    ResourceRequest request;
    for (;;) {
        if (xQueueReceive(resourceQueue, &request, [1]) == pdPASS) {
            // Process the request
            processResource(request.data);
            xTaskNotifyGive([2]);
        }
    }
}
Drag options to blanks, or click blank then click option'
AportMAX_DELAY
Brequest.taskHandle
CNULL
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong block time values.
Not notifying the correct task handle.