All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Event flag anomaly
@ 2006-01-31 12:28 ROSSIER Daniel
  2006-01-31 13:26 ` Philippe Gerum
  0 siblings, 1 reply; 2+ messages in thread
From: ROSSIER Daniel @ 2006-01-31 12:28 UTC (permalink / raw)
  To: xenomai



Hi,

I've some problems to understand how the event flag semantic is defined.

In the example below, I just defined a RT_EVENT task which waits on event mask 1.
(Simply bit 1 has to be set). 
When I do a rt_event_signal(&meteoEvents, 1) from another task, the blocking task
is logically waked up. Fine. On the next iteration, the event bit set is remaining
unchanged and the rt_event_wait() doesn't wait anymore since the event is activated.
(please consider the rt_event_clear as commented lines as it is). Well, it seems
OK. BUT, on the third iteration, the rt_event_wait() is blocking! Actually, the bit
set has been cleared in the meanwhile.

Looking at the rt_event_wait() code in native/event.c, it effectively turns out that
the bit set is cleared according to the mask, if and only if the task doesn't need to wait.

Please could you explain me what's the rationale behind this strange behaviour? I would propose that the bits
remain unchanged until a clear().  (I probably missed something in my reasoning).

Here is the example:
---------------------------

void meteoDataAcquisition(void *cookie) {

unsigned long receivedMask;

  while(1) {

    rt_event_wait(&meteoEvents, 1, &receivedMask, EV_ANY, TM_INFINITE);
    //rt_event_clear(&meteoEvents, 1, &receivedMask);
    
    
    printk("#Task activated\n");
   
  }
  
}
-------------------------------

And a piece of code from event.c

....
 if (((mode & EV_ANY) && (mask & event->value) != 0) ||
        (!(mode & EV_ANY) && ((mask & event->value) == mask)))
        {
        *mask_r = (event->value & mask);
        event->value &= ~mask;        --> this is not done after the thread has been waked up.
        goto unlock_and_exit;
        }
.....




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Xenomai-help] Event flag anomaly
  2006-01-31 12:28 [Xenomai-help] Event flag anomaly ROSSIER Daniel
@ 2006-01-31 13:26 ` Philippe Gerum
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Gerum @ 2006-01-31 13:26 UTC (permalink / raw)
  To: ROSSIER Daniel; +Cc: xenomai

ROSSIER Daniel wrote:
> 
> Hi,
> 
> I've some problems to understand how the event flag semantic is defined.
> 
> In the example below, I just defined a RT_EVENT task which waits on event mask 1.
> (Simply bit 1 has to be set). 
> When I do a rt_event_signal(&meteoEvents, 1) from another task, the blocking task
> is logically waked up. Fine. On the next iteration, the event bit set is remaining
> unchanged and the rt_event_wait() doesn't wait anymore since the event is activated.
> (please consider the rt_event_clear as commented lines as it is). Well, it seems
> OK. BUT, on the third iteration, the rt_event_wait() is blocking! Actually, the bit
> set has been cleared in the meanwhile.
> 
> Looking at the rt_event_wait() code in native/event.c, it effectively turns out that
> the bit set is cleared according to the mask, if and only if the task doesn't need to wait.
> 
> Please could you explain me what's the rationale behind this strange behaviour? I would propose that the bits
> remain unchanged until a clear().  (I probably missed something in my reasoning).

You are right. Auto-clearing the satisfied event bits is spurious here. Fixed, thanks.

> 
> Here is the example:
> ---------------------------
> 
> void meteoDataAcquisition(void *cookie) {
> 
> unsigned long receivedMask;
> 
>   while(1) {
> 
>     rt_event_wait(&meteoEvents, 1, &receivedMask, EV_ANY, TM_INFINITE);
>     //rt_event_clear(&meteoEvents, 1, &receivedMask);
>     
>     
>     printk("#Task activated\n");
>    
>   }
>   
> }
> -------------------------------
> 
> And a piece of code from event.c
> 
> ....
>  if (((mode & EV_ANY) && (mask & event->value) != 0) ||
>         (!(mode & EV_ANY) && ((mask & event->value) == mask)))
>         {
>         *mask_r = (event->value & mask);
>         event->value &= ~mask;        --> this is not done after the thread has been waked up.
>         goto unlock_and_exit;
>         }
> .....
> 
> 
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
> 


-- 

Philippe.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-31 13:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-31 12:28 [Xenomai-help] Event flag anomaly ROSSIER Daniel
2006-01-31 13:26 ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.