0
0
FreeRTOSprogramming~10 mins

Graceful shutdown sequence 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 notify the shutdown event.

FreeRTOS
xEventGroupSetBits(shutdownEventGroup, [1]);
Drag options to blanks, or click blank then click option'
ASHUTDOWN_BIT
BSTART_BIT
CERROR_BIT
DRUNNING_BIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using START_BIT instead of SHUTDOWN_BIT.
Forgetting to set any event bit.
Using ERROR_BIT which signals errors, not shutdown.
2fill in blank
medium

Complete the code to wait for the shutdown event.

FreeRTOS
xEventGroupWaitBits(shutdownEventGroup, [1], pdTRUE, pdFALSE, portMAX_DELAY);
Drag options to blanks, or click blank then click option'
ASHUTDOWN_BIT
BERROR_BIT
CSTART_BIT
DRUNNING_BIT
Attempts:
3 left
💡 Hint
Common Mistakes
Waiting on START_BIT which is unrelated to shutdown.
Using pdFALSE for clearOnExit incorrectly.
Not using portMAX_DELAY to wait indefinitely.
3fill in blank
hard

Fix the error in the shutdown task loop condition.

FreeRTOS
while (![1](shutdownEventGroup, SHUTDOWN_BIT, pdTRUE, pdFALSE, 0)) {
    vTaskDelay(pdMS_TO_TICKS(100));
}
Drag options to blanks, or click blank then click option'
AxEventGroupSync
BxEventGroupWaitBits
CxEventGroupSetBits
DxEventGroupClearBits
Attempts:
3 left
💡 Hint
Common Mistakes
Using xEventGroupSetBits which sets bits instead of waiting.
Using xEventGroupClearBits which clears bits but does not wait.
Using xEventGroupSync which is for synchronization, not bit checking.
4fill in blank
hard

Fill both blanks to correctly stop peripherals and delete the task.

FreeRTOS
stopPeripheral([1]);
vTaskDelete([2]);
Drag options to blanks, or click blank then click option'
AperipheralHandle
BNULL
CtaskHandle
DperipheralID
Attempts:
3 left
💡 Hint
Common Mistakes
Passing taskHandle to stopPeripheral instead of peripheral ID.
Passing NULL to stopPeripheral which expects an ID.
Passing taskHandle to vTaskDelete instead of NULL.
5fill in blank
hard

Fill all three blanks to create a graceful shutdown sequence with notification, wait, and cleanup.

FreeRTOS
xEventGroupSetBits(shutdownEventGroup, [1]);

xEventGroupWaitBits(shutdownEventGroup, [2], pdTRUE, pdFALSE, portMAX_DELAY);

cleanupResources([3]);
Drag options to blanks, or click blank then click option'
ASHUTDOWN_BIT
CresourceHandle
DtaskHandle
Attempts:
3 left
💡 Hint
Common Mistakes
Using different bits for set and wait causing deadlock.
Passing taskHandle instead of resourceHandle to cleanupResources.
Not waiting for shutdown event before cleanup.