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


> -----Original Message-----
> From: Nick Garnett [mailto:nickg at ecoscentric dot com]
> Sent: Wednesday, February 19, 2003 11:06 AM
> To: Fabrice Gautier
> Cc: 'Jonathan Larmour'; Ecos-List (E-mail)
> Subject: Re: [ECOS] Wait on multiple objects
> 
> 
> The only operating system I know of that has a fully general
> wait-on-anything architecture is NT. Do you really want eCos to become
> like NT? :-)

Well, that would be an interresting concept.. but no, i would be just fine
if i could wait on multiple object of the same kind, flags for example.

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);
    }

    do {
		
	count=0; 
	// test flag values
	for(u=0; u<nfls; u++) {
	    if((ufls[u].rvalue=cyg_flag_poll(ufls[u].flag,ufls[u].value,
					 CYG_FLAG_WAIT_MODE_OR))){
		count++;
	    }
	}
	// we got an event, break out.
	if(count) break;

	// go to sleep
	self->set_sleep_reason( Cyg_Thread::WAIT );
	self->sleep();
	
	// allow other threads to run...
	Cyg_Scheduler::reschedule();

	// Check wakeup reason sometime...
	
    } while(1);
	
    // remove from queues 
    for(u=0; u<nfls; u++) {
        Cyg_Flag *flag=(Cyg_Flag *)ufls[u];
        flag->queue.remove(self);
    }

    Cyg_Scheduler::unlock();
    
    return count;
}

/************/

Off course it doesnt work because flag->queue is private, and it's also
missing a few things like timeout and I dont check the wakeup reason after
reschedule... But it seems to me that the idea is not that bad...

Regards,

Fabrice Gautier

-- 
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]