4 Event Groups Flashcards
What is an event group?
An event group is a group of bits or flags. An event group allows a task to be in a blocked state until an event or combination of event occur.
Why are event flags used?
An event flag is used to indicate if an event has occurred or not.
How many event flags can an event group store?
24, bits 0 to 23.
What is the difference between an event group and semaphore when unblocking tasks?
Event groups can unblock multiple tasks, a semaphore can only unblock a single task.
A semaphore allows a task to wait in a blocked state until a single event occurs.
What advantages does an event group have over a semaphore?
Can synchronise multiple task,
It can unblock multiple tasks,
Allow a task to remain in a blocked state until a combination of events occur,
An event group uses less RAM then multiple binary semaphores.
How do you create an event group?
Declare an event group variable:
EventGroupHandle_t SW_EventGroup = NULL;
Create the event group in main()
SW_EventGroup = xEventGroupCreate();
How do you set an event group bit(s)?
define BIT0 (1«0)
xEventGroupSetBits(SW_EventGroup, BIT0)
For Multiple Bits
xEventGroupSetBits(SW_EventGroup, BIT0 | BIT1)
How to wait on event group bit(s)?
xEventGroupWaitBits(SW_EventGroup, BIT0, pdTrue, pdFalse, portMAX_DELAY)