This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wait on multiple objects


Fabrice Gautier <Fabrice_Gautier at sdesigns dot com> writes:

> 
> I dont really understand your proxy stuff but I was thinking of something
> like that, which is basically like "poll" but on flags:
> 
> /*************/
> 
> struct pollfl {
>     cyg_flag_t *flag;
>     cyg_uint32 value;
>     cyg_uint32 rvalue;
> };
> 
> int flag_poll(struct pollfl *ufls, unsigned int nfls)
> {
>     unsigned int u;
>     int count;
>     Cyg_Thread *self = Cyg_Thread::self();
>     
>     Cyg_Scheduler::lock();
> 
>     //add thread to multiple queues
>     for(u=0; u<nfls; u++) {
>         Cyg_Flag *flag=(Cyg_Flag *)ufls[u];
> 	  flag->queue.enqueue(self);

This is the bit that doesn't work. Each thread only has one list node
for adding to a queue. You cannot add a thread directly to more than
one queue.

Instead what you have to add to each queue is some other kind of
object, a proxy, which sits on the queue in place of the thread. All
thread queues then have to work this way and you have all sorts of
problems putting proxies on to queues and taking them off atomically,
timeouts, cancellations, thread and object destruction...

Trust me, I've looked at this sort of thing, and run away screaming :-)

-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]