Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to notify the shutdown event.
FreeRTOS
xEventGroupSetBits(shutdownEventGroup, [1]); Drag options to blanks, or click blank then click option'
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.
✗ Incorrect
The shutdown event is signaled by setting the SHUTDOWN_BIT in the event group.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
Waiting for SHUTDOWN_BIT ensures the task blocks until shutdown is requested.
3fill in blank
hardFix the error in the shutdown task loop condition.
FreeRTOS
while () { vTaskDelay(pdMS_TO_TICKS(100)); }
Drag options to blanks, or click blank then click option'
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.
✗ Incorrect
xEventGroupWaitBits is used to check event bits with timeout; others do not return bit status.
4fill in blank
hardFill 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'
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.
✗ Incorrect
stopPeripheral needs the peripheral ID; vTaskDelete(NULL) deletes the current task.
5fill in blank
hardFill 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'
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.
✗ Incorrect
Set and wait on SHUTDOWN_BIT to coordinate shutdown; cleanupResources needs the resource handle.