This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
AW: AW: AW: Blocking restricted in DSRs
- From: "Neundorf, Alexander" <Alexander dot Neundorf at jenoptik dot com>
- To: "Nick Garnett" <nickg at ecoscentric dot com>, <ecos-discuss at sources dot redhat dot com>
- Date: Tue, 27 Jul 2004 13:06:00 +0200
- Subject: AW: AW: AW: [ECOS] Blocking restricted in DSRs
> -----Ursprüngliche Nachricht-----
> Von: ecos-discuss-owner@ecos.sourceware.org
> [mailto:ecos-discuss-owner@ecos.sourceware.org]Im Auftrag von
> Neundorf,
> Alexander
> Gesendet: Dienstag, 27. Juli 2004 12:44
> An: Nick Garnett; ecos-discuss@sources.redhat.com
> Betreff: AW: AW: AW: [ECOS] Blocking restricted in DSRs
>
>
>
> ...
> > > Ok, and what to do with the variables which are modified and which
> > > should be protected by the mutex ? E.g. if I have a
> queue which is
> > > filled by the DSR, and which is checked by the thread which waits
> > > for the signal. Actually I have to ensure that the "take
> element out
> > > of queue" by the thread is protected against the "put element into
> > > queue" by the DSR. Do I have to use cyg_scheduler_lock() in the
> > > thread to achieve this ?
> >
> > Yes. Take a look at the generic serial driver for an
> example of how to
> > do this.
>
> Ok, I had a look. The generic serial driver doesn't use
> cyg_sched_lock() (at least I didn't find it).
Well, it's not in devs/serial/generic, but in io/serial/current.
So I guess I finally found it:
while (1) //thread main loop
{
cyg_drv_dsr_lock(); //does the order of the dsr_lock() and mutex_lock() calls matter ?
cyg_mutex_lock(mutex);
while (queue.isEmpty())
cyg_cond_timed_wait(condition);
Item *i=queue.pop();
cyg_mutex_unlock(mutex);
cyg_drv_dsr_unlock();
//do something with i
...
}
Bye
Alex
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss