This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Wait on multiple objects
- From: Nick Garnett <nickg at ecoscentric dot com>
- To: Fabrice Gautier <Fabrice_Gautier at sdesigns dot com>
- Cc: 'Jonathan Larmour' <jifl at eCosCentric dot com>,"Ecos-List (E-mail)" <ecos-discuss at sources dot redhat dot com>
- Date: 19 Feb 2003 23:43:44 +0000
- Subject: Re: [ECOS] Wait on multiple objects
- References: <9F77D654ED40B74CA79E5A60B97A087B042415@sd-exchange.sdesigns.com>
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