This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: ECOS: fatal error!
- From: Martin Buck <martin dot buck at ascom dot ch>
- To: ecos-discuss at sources dot redhat dot com
- Date: Thu, 27 Jun 2002 10:16:35 +0200
- Subject: Re: [ECOS] ECOS: fatal error!
- Newsgroups: local.ecos.discuss
- Organization: Ascom Systec AG
- References: <20020626103346.20814.qmail@sina.com> <200206261457.20769.iz@vsr.si>
Iztok Zupet wrote:
> No You can't call semaphore::post from ISR/DSR directly. ! In fact, You can't
> call kernel from there directly.
Of course you can (in the DSR, that is). To cite the eCos reference
manual, section "Interrupt and exception handlers":
------------------------------------------------------------------
Interrupt handlers are actually a pair of functions, one of which (the
interrupt service routine, or ISR ) is executed immediately and runs
with that interrupt disabled. Since interrupts are disabled for the
duration of the ISR, the ISR should be very brief and should not use any
system services.
After the ISR exits, but before the kernel scheduler is invoked again, a
delayed service routine ( DSR ) will be invoked. It executes with
scheduling disabled, but with interrupts enabled, so that further
invocations of the same DSR can be queued. The DSR can use some
producer-side system calls, but it should be carefully crafted to avoid
using any call that might put its thread to sleep. One of the few
examples of safe calls is cyg_semaphore_post() ; the non-blocking
versions of some system calls are also safe. A call that is unsafe is
cyg_mutex_lock() , since it will block if the mutex is already locked by
another thread.
------------------------------------------------------------------
That's the whole reason of the ISR/DSR split: The scheduler makes sure
to run the DSRs only when it's safe to do so, i.e. when the scheduler is
not in some unknown state. You're probably confusing this with what's
stated in section "Device Driver Interface to the Kernel", which is a
completely different thing, since device drivers are supposed to use
only a small subset of eCos system calls anyway (cyg_drv_*).
Martin
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss