public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* AW: AW: [ECOS] Blocking restricted in DSRs
@ 2004-07-27 10:41 Neundorf, Alexander
  2004-07-27 10:44 ` Nick Garnett
  0 siblings, 1 reply; 2+ messages in thread
From: Neundorf, Alexander @ 2004-07-27 10:41 UTC (permalink / raw)
  To: ecos-discuss


...
> > Ok, the docu says sending signals to condition variables is ok from
> > a DSR. But AFAIK this has always be done together with locking the
> > associated mutex first... from the DSR then. But the docu also says
> > using cyg_mutex_lock() should be used only from thread context, not
> > from DSR. So, what's the right way then ?
> 
> It also says that cyg_mutex_signal() can be called without locking the
> associated mutex first. This is how it must be used from the DSR.

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 ?

The code with mutex looks like this:

cyg_mutex_lock(mutex);
while (queue.isEmpty())
   cyg_cond_wait(condition);
Item* i=queue.pop();
cyg_mutex_unlock(mutex);

DSR will be:

Item i;
queue.append(&i);
cyg_cond_signal(condition);

So how do I "translate" this correctly to use cyg_sched_lock() ?


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: AW: AW: [ECOS] Blocking restricted in DSRs
  2004-07-27 10:41 AW: AW: [ECOS] Blocking restricted in DSRs Neundorf, Alexander
@ 2004-07-27 10:44 ` Nick Garnett
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Garnett @ 2004-07-27 10:44 UTC (permalink / raw)
  To: Neundorf, Alexander; +Cc: ecos-discuss

"Neundorf, Alexander" <Alexander.Neundorf@jenoptik.com> writes:

> ...
> > > Ok, the docu says sending signals to condition variables is ok from
> > > a DSR. But AFAIK this has always be done together with locking the
> > > associated mutex first... from the DSR then. But the docu also says
> > > using cyg_mutex_lock() should be used only from thread context, not
> > > from DSR. So, what's the right way then ?
> > 
> > It also says that cyg_mutex_signal() can be called without locking the
> > associated mutex first. This is how it must be used from the DSR.
> 
> 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.

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


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-27 10:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-27 10:41 AW: AW: [ECOS] Blocking restricted in DSRs Neundorf, Alexander
2004-07-27 10:44 ` Nick Garnett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).