An event group is a collection of bits used to synchronize tasks by setting, clearing, or waiting for specific bits to be set. It helps tasks communicate and coordinate actions.
Click to reveal answer
beginner
How do tasks wait for an event in an event group?
Tasks use the function xEventGroupWaitBits() to wait for one or more bits to be set in the event group. The task can block until the bits are set or timeout.
Click to reveal answer
beginner
What does setting a bit in an event group mean?
Setting a bit means marking that a particular event or condition has occurred. Other tasks waiting for that bit can then proceed.
Click to reveal answer
beginner
Which FreeRTOS function is used to set bits in an event group?
The function xEventGroupSetBits() is used to set one or more bits in an event group, signaling that events have occurred.
Click to reveal answer
intermediate
Why use event groups instead of direct task notifications for synchronization?
Event groups allow multiple bits to represent multiple events, enabling tasks to wait for combinations of events. This is more flexible than single-value notifications.
Click to reveal answer
Which function waits for bits in an event group in FreeRTOS?
AxEventGroupSetBits()
BxTaskNotifyWait()
CvTaskDelay()
DxEventGroupWaitBits()
✗ Incorrect
xEventGroupWaitBits() blocks the task until the specified bits are set in the event group.
What does xEventGroupSetBits() do?
AClears bits in an event group
BSets bits in an event group
CCreates a new event group
DDeletes an event group
✗ Incorrect
xEventGroupSetBits() sets one or more bits in the event group to signal events.
If a task wants to wait for multiple events at once, what should it use?
AEvent group with multiple bits
BMultiple event groups
CMultiple task notifications
DvTaskDelay()
✗ Incorrect
An event group can hold multiple bits, allowing a task to wait for multiple events simultaneously.
What happens if xEventGroupWaitBits() times out before bits are set?
AThe task continues without the bits set
BThe task blocks forever
CThe event group is deleted
DThe bits are automatically set
✗ Incorrect
If the timeout expires, the function returns and the task continues even if the bits were not set.
Which of these is NOT a benefit of using event groups?
ASynchronizing multiple tasks
BWaiting for multiple events
CSending large data between tasks
DSignaling event occurrence
✗ Incorrect
Event groups are for signaling events, not for sending large data between tasks.
Explain how event groups help synchronize tasks in FreeRTOS.
Think about how tasks know when to start or stop based on shared signals.
You got /4 concepts.
Describe the difference between xEventGroupSetBits() and xEventGroupWaitBits().
One function signals events, the other waits for them.
You got /4 concepts.
Practice
(1/5)
1. What is the primary purpose of an event group in FreeRTOS for task synchronization?
easy
A. To allocate memory dynamically for tasks
B. To allow tasks to wait for multiple events using bits
C. To create queues for message passing
D. To manage task priorities automatically
Solution
Step 1: Understand event groups in FreeRTOS
Event groups use bits to represent events that tasks can wait for or signal.
Step 2: Identify the main use of event groups
They help tasks synchronize by waiting on or setting bits representing events.
Final Answer:
To allow tasks to wait for multiple events using bits -> Option B
Quick Check:
Event groups = wait for multiple events [OK]
Hint: Event groups use bits to sync tasks, not memory or priorities [OK]
Common Mistakes:
Confusing event groups with queues
Thinking event groups manage memory
Assuming event groups change task priorities
2. Which of the following is the correct function to wait for bits in an event group in FreeRTOS?
easy
A. xEventGroupClearBits()
B. xEventGroupSetBits()
C. xEventGroupWaitBits()
D. xEventGroupCreate()
Solution
Step 1: Recall FreeRTOS event group functions
xEventGroupWaitBits() is used to wait for specific bits to be set.
Step 2: Differentiate from other functions
xEventGroupSetBits() sets bits, ClearBits clears bits, Create creates the group.
Final Answer:
xEventGroupWaitBits() -> Option C
Quick Check:
Wait for bits = xEventGroupWaitBits() [OK]
Hint: Wait uses xEventGroupWaitBits(), set uses xEventGroupSetBits() [OK]
Common Mistakes:
Using xEventGroupSetBits() to wait
Confusing create with wait functions
Mixing clear bits with wait bits
3. Given the following code snippet, what will be the value of bits after xEventGroupWaitBits() returns?
C. Using pdFALSE for clearOnExit in xEventGroupWaitBits
D. Setting bits before event group creation
Solution
Step 1: Check event group creation
xEventGroupCreate() can return NULL if creation fails; code does not check this.
Step 2: Verify other parameters
Using pdFALSE for clearOnExit is valid; portMAX_DELAY is valid; bits are set after creation.
Final Answer:
Not checking if eventGroup creation succeeded -> Option A
Quick Check:
Always check event group creation success [OK]
Hint: Always verify event group creation returned non-NULL [OK]
Common Mistakes:
Ignoring NULL return from xEventGroupCreate
Misusing clearOnExit parameter
Setting bits before creating event group
5. You want two tasks to synchronize so that Task A waits until Task B signals both BIT_0 and BIT_1. Which xEventGroupWaitBits() call correctly waits for both bits before continuing?
hard
A. xEventGroupWaitBits(eventGroup, BIT_0 | BIT_1, pdTRUE, pdTRUE, portMAX_DELAY);
B. xEventGroupWaitBits(eventGroup, BIT_0 & BIT_1, pdTRUE, pdTRUE, portMAX_DELAY);
C. xEventGroupWaitBits(eventGroup, BIT_0 | BIT_1, pdTRUE, pdFALSE, portMAX_DELAY);
D. xEventGroupWaitBits(eventGroup, BIT_0 & BIT_1, pdFALSE, pdFALSE, portMAX_DELAY);
Solution
Step 1: Understand wait for all bits parameter
The fourth parameter (xWaitForAllBits) must be pdTRUE to wait for both bits together.
Step 2: Check bit mask and parameters
Use BIT_0 | BIT_1 to specify both bits; pdTRUE for clearOnExit clears bits after wait.
Final Answer:
xEventGroupWaitBits(eventGroup, BIT_0 | BIT_1, pdTRUE, pdTRUE, portMAX_DELAY); -> Option A
Quick Check:
Wait for all bits = xEventGroupWaitBits with xWaitForAllBits = pdTRUE [OK]
Hint: Set xWaitForAllBits to pdTRUE to wait for all bits [OK]
Common Mistakes:
Using bitwise AND (&) instead of OR (|) for bit mask
Setting xWaitForAllBits to pdFALSE when waiting for all bits
Confusing clearOnExit with wait for all bits
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.