Wednesday, February 6, 2013

3.1 Event Groups, Event Componets

In MQX, there is an entity called Event Component.
Overall hierarchy is like this:  Event component has event group and Event groups have events. And each event group has events.

If you do not exclusively create event component, one default one gets created at the time when you create an event group. So bottom line is MQX supports more events that any sane RTOS application would ever need.

Below discussion is regarding light weight events.
 

Event Group

Each event in event group normally can contain number of events equal to bits present in _mqx_uint (on most of platforms its 32).

Creating event group is also straight forward.
You need to allocate global storage by declaring array which can hold number of event groups you want to create. OR in short declared an array of Event Groups.

Then you need to ask  kernel to initialize it (i.e. setting up data structure like list of waiting tasks, current bit value of it, flags associated with event etc. This is achieved by kernel call named  "_lwevent_create".


A word about kernel calls

As with most of other kernel calls, _lwevent_create this call internal  would be
1)disable interrupts
2)Get kernel data pointer
3)What ever event group pointer you have passed, hook it with kernel. ie. kernel data pointers would point to this location
4)enable interrupt

Steps 1,2,4 are invariably common while creating/updating any kernel entity.




Subsequently, while setting/clearing events and you have to give event group and particular event bit position.



MQX interrupts post is here