rtems_event_receive() return code question

Thomas Rauscher trauscher at loytec.com
Mon Feb 2 17:35:12 UTC 2004

> -----Original Message-----
> From: Sergei Organov [mailto:osv at topconrd.ru] 
> Sent: Monday, February 02, 2004 6:13 PM
> To: Thomas Rauscher
> Cc: rtems-users at rtems.com
> Subject: Re: rtems_event_receive() return code question
> "Thomas Rauscher" <trauscher at loytec.com> writes:
> > Hi,
> > 
> > I've a question regarding the rtems_event_receive() semantics.
> > The API documentation unfortunately leaves some open questions.
> > 
> > If a rtems_event_receive() function is called with timeout, but
> > receives events just while returning after a timeout, is it 
> correct to
> > return RTEMS_TIMEOUT but have the event_out parameter set to
> > a satisfying event set?
> While not explicitly documented, the 'event_out' is left untouched
> RTEMS_TIMEOUT is returned. Thus, you need to initialize it to 0 before
> rtems_event_receive() (it's almost always a good idea to 
> initialize all your variables anyway). Alternatively, check return
code and don't 
> use 'event_out' when something other than RTEMS_SUCCESSFUL is

Well, in my case *event_out is always zero before being used.

I think, that the code path I'm talking about, includes a race condition
when the rtems_event_receive() caller actually is dispatched after
Then the return code is RTEMS_TIMEOUT and 'event_out' is changed.

At least I didn't see that the Wait.count variable of the waiting thread

is set to zero by the _Event_Timeout() function, like it is done by the
_Event_Surrender() function. This was added 2001 or so,
as it fixes a bug when sending events from interrupt service handlers.

Please correct me, if I'm wrong.

BTW, I can happily live with a return code of RTEMS_TIMEOUT and set 
output events. I just wanted to make sure that this is the intended

Best regards,

Thomas Rauscher
LOYTEC electronics GmbH
Stolzenthalergasse 24/3
A-1080 Wien
trauscher at loytec.com
Phone: +43-1-4020805-15
FAX:   +43-1-4020805-99

More information about the users mailing list