0
0
FreeRTOSprogramming~20 mins

Event-driven architecture in FreeRTOS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Event-Driven Mastery in FreeRTOS
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Event Group Bits Setting and Clearing
What is the output of this FreeRTOS code snippet that uses event groups to set and clear bits?
FreeRTOS
EventGroupHandle_t eventGroup = xEventGroupCreate();

xEventGroupSetBits(eventGroup, (1 << 0));
xEventGroupSetBits(eventGroup, (1 << 1));

EventBits_t bits = xEventGroupClearBits(eventGroup, (1 << 0));

printf("Bits before clear: 0x%X\n", bits);
printf("Bits after clear: 0x%X\n", xEventGroupGetBits(eventGroup));
A
Bits before clear: 0x2
Bits after clear: 0x1
B
Bits before clear: 0x1
Bits after clear: 0x3
C
Bits before clear: 0x3
Bits after clear: 0x2
D
Bits before clear: 0x0
Bits after clear: 0x0
Attempts:
2 left
💡 Hint
Remember that xEventGroupClearBits returns the bits before clearing.
🧠 Conceptual
intermediate
1:30remaining
Understanding Event-Driven Task Notification
In FreeRTOS, which statement best describes the behavior of task notifications used as lightweight event flags?
ATask notifications require a separate queue to send data between tasks.
BTask notifications can only be used to unblock a task and cannot carry data.
CTask notifications automatically queue multiple events if sent rapidly.
DTask notifications can be used both to unblock a task and to send 32-bit data atomically.
Attempts:
2 left
💡 Hint
Think about how task notifications combine signaling and data transfer.
🔧 Debug
advanced
2:30remaining
Debugging Event Group Wait Timeout
A task waits for bits 0x01 and 0x02 using xEventGroupWaitBits with the wait option to clear bits on exit. The task never proceeds even though another task sets bit 0x01. What is the most likely cause?
FreeRTOS
xEventGroupWaitBits(eventGroup, 0x03, pdTRUE, pdTRUE, portMAX_DELAY);
AThe wait condition requires both bits 0x01 and 0x02 to be set, but only 0x01 is set.
BThe bits are cleared before the wait, causing the function to return immediately.
CThe event group handle is NULL, so the wait never succeeds.
DThe task priority is too low to run after the bits are set.
Attempts:
2 left
💡 Hint
Check the 'wait for all bits' parameter and which bits are set.
📝 Syntax
advanced
1:00remaining
Identify the Syntax Error in Event Group Creation
Which option contains the correct syntax to create an event group in FreeRTOS?
AEventGroupHandle_t eg = xEventGroupCreate();
BEventGroupHandle_t eg = xEventGroupCreate;
CEventGroupHandle_t eg = xEventGroupCreate[];
DEventGroupHandle_t eg = xEventGroupCreate();;
Attempts:
2 left
💡 Hint
Remember that xEventGroupCreate is a function that returns a handle.
🚀 Application
expert
3:00remaining
Designing an Event-Driven Task Synchronization
You want to synchronize three tasks so that each waits until all three have reached a certain point before continuing. Which FreeRTOS event-driven mechanism is best suited for this?
AUse a counting semaphore initialized to zero and each task gives once, then all tasks take once.
BUse an event group where each task sets its own bit and all tasks wait for all bits to be set.
CUse a binary semaphore that each task takes and gives to signal readiness.
DUse task notifications with each task notifying the others directly.
Attempts:
2 left
💡 Hint
Think about a mechanism that can track multiple flags and wait for all.