[En-Nut-Discussion] RFC: Wait for Multiple Events
Henrik Maier
hmlists at focus-sw.com
Fri Apr 28 02:55:12 CEST 2006
Hello Matthias,
I would support such an approach (refer to my post "Asynchronous signals
- waking up blocked threads" from 28/3) as I also like to wake up a
blocked thread with multiple events (and/or signals). I like to use it
for example to block a thread until one of the three conditions are true:
1. data received (read call for example)
2. time-out
3. Configuration change notification from supervisory thread
Could this be achieved with your method?
Best Regards
Henrik Maier
Ringwald wrote:
> Hi all,
> I'd like to share with you a (I hope) clean & straight & easy solution
> to the problem,
> that a thread has no easy way to wait for several events to happen
> without polling.
>
> RFC: Wait for Multiple Events
>
> It would be useful for a thread to wait on multiple events.
> A straight forward way to implement this could be the introduction of
> signals. A set of signals, e.g. 16, can be used similar as the current
> event queues.
>
> For this to work, a mask of awaited (or triggering) signals need to be
> stored in the thread struct (+2 bytes) and to allow for signals to be
> sent without anyone waiting, the queue needs to also store a signal mask
> (signal queue size = pointer + signal mask = 4 bytes on AVR).
>
> In the signal post function, the signal queue has to be searched for the
> first thread with a matching signal mask and set to runnable.
>
> As this is in the order of threads, I would not use this within IRQs.
> But, if the signal queue contains an event queue at the first byte,
> NutEventPost|Broadcast can be directly called on a signal queue as well.
> In this case, the first or all threads in the queue will be awaken
> regardless of the signal settings. Hence NutEventPostIrq can also be
> used to wake up the first thread in a signal queue from an interrupt
> service handler.
>
> New functions:
> NutSignal[Post|Broadcast][async]( SignalQueue, signalNr);
> NutSignalWait( SignalQueue, signalPattern);
>
> Thanks for sharing your opinions on this,
> Matthias
>
>
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
>
>
More information about the En-Nut-Discussion
mailing list