Thought Leadership

RTOS event groups

By Colin Walls

This is the latest in my occasional series of posts about RTOS features and I want to talk about event groups – also called event flags. This is a feature available in many RTOS products, including, of course, our own Nucleus RTOS. Although my comments are inspired by the Nucleus implementation, they are very similar in other RTOSes …

An event group is a set of 1-bit flags. In Nucleus, an event group has 32 flags, but other RTOSes may offer 8- or 16-flag groups. An event group is a standalone object – it does not “belong” to any specific task. Their purpose is to provide a very simple, but flexible, intertask communications mechanism. They are normally used for one task to advise another that some kind of event has occurred.

Any task can set or clear event flags. This may be done using AND/OR operations, which enables any number of flags in a group to be set to 1 or 0 [or not be changed].

Another task can “retrieve” the flags. This may be done by reading their state, which may be performed with a task suspend that pends on a specific flag, one of several flags or a combination of flags. The retrieve process may also “consume” the flags; this means that the flags are cleared down by the process of retrieval.

When designing a multithreaded embedded application, intertask communication and synchronization needs to be considered. Event flags provide a very simple mechanism with low overhead, that may be used in many applications.

Comments

One thought about “RTOS event groups

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at https://blogs.sw.siemens.com/embedded-software/2017/11/27/rtos-event-groups/