This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Calling cyg_mbox_trypost() from DSR
- From: Bart Veer <bartv at ecoscentric dot com>
- To: fpagliughi at mindspring dot com
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Thu, 7 Apr 2005 23:10:43 +0100 (BST)
- Subject: Re: [ECOS] Calling cyg_mbox_trypost() from DSR
- References: <JMEAKDCKCGBKENKKKJIGAECECHAA.fpagliughi@mindspring.com>
>>>>> "Frank" == Frank Pagliughi <fpagliughi@mindspring.com> writes:
Frank> Is it safe to call cyg_mbox_trypost() from a DSR? There's
Frank> some differing info in various documents, but I've seen it
Frank> on this mailing list as a solution for several different
Frank> problems.
Frank> It appears to use Cyg_Scheduler::lock() for
Frank> synchronization. Is that safe from a DSR? What if two DSR's
Frank> are posting to the same mbox? Could they interrupt each
Frank> other, or are DSR's serialized?
I assume you mean cyg_mbox_tryput(). See the last sentence @
http://ecos.sourceware.org/docs-latest/ref/kernel-mail-boxes.html
That is the authorative documentation, and explicitly lists
cyg_mbox_tryput() as callable from a DSR.
DSRs are serialized via the scheduler lock, that is what allows them
to manipulate kernel data structures without worrying about context
switches at an inconvenient moment. The scheduler is already locked on
entry to the DSR, and the call to Cyg_Scheduler::lock() just
increments a counter. Of course tryput() can also be called from
thread context, in which case locking the scheduler would be
essential.
The main problem with calling tryput() from a DSR is how to recover
when the tryput() fails. Presumably the DSR is trying to communicate
an event and some data to a thread. Some applications can cope if this
data is just discarded, but not all.
Bart
--
Bart Veer eCos Configuration 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