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]

Calling cyg_mbox_trypost() from DSR


Hey All,

Is it safe to call cyg_mbox_trypost() from a DSR? There's some differing
info in various documents, but I've seen it on this mailing list as a
solution for several different problems.

It appears to use Cyg_Scheduler::lock() for synchronization. Is that safe
from a DSR? What if two DSR's are posting to the same mbox? Could they
interrupt each other, or are DSR's serialized?

Thanks
Frank

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org]On Behalf Of Andrew Lunn
Sent: Wednesday, March 23, 2005 1:41 PM
To: Wayne Gemmell
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Event based programming in ecos


On Wed, Mar 23, 2005 at 05:17:44PM +0200, Wayne Gemmell wrote:
> Hi all
>
> I'm looking to make an event based program. Is there any easy way to
> do this?  Could you please give me some directions, links. I was
> thinking of running a loop to monitor the sensors but this doesn't
> strike me as efficient and could possibly be done better with
> interrupts and threads.

eCos's message boxes are ideal for event loops. You have a thread
which simply takes takes messages out of the message box and acts on
them. The message box gives you a void * which is ideal as a pointer
to the actual message.

Your sensors can then be interrupt driver. The DSR or a thread which
is woken up then posts a message to message box with the results from
the sensor. Just be careful not to use the blocking cyg_mbox_put()
from the DSR. You need to either use cyg_mbox_tryput() and handle the
case when the message box is full, or have the DSR signal a thread to
to the cyg_mbox_put() which can then block.

        Andrew

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




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


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