Thought Leadership

RTOS event groups

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.

Colin Walls

I have over thirty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles and two books on embedded software, I am a member of the marketing team of the Mentor Graphics Embedded Systems Division, and am based in the UK. Away from work, I have a wide range of interests including photography and trying to point my two daughters in the right direction in life. Learn more about Colin, including his go-to karaoke song and the best parts of being British: http://go.mentor.com/3_acv

More from this author

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/