This is the mail archive of the
mailing list for the eCos project.
Re: Knowing current context
- From: Nick Garnett <nickg at ecoscentric dot com>
- To: David Brennan <eCos at brennanhome dot com>
- Cc: ecos-patches at sources dot redhat dot com
- Date: 25 Oct 2004 09:58:33 +0100
- Subject: Re: Knowing current context
- References: <417A7991.email@example.com>
David Brennan <eCos@brennanhome.com> writes:
> For our application, it is desirable to know if a section of code is
> running in interrupt context. (Specifically we have a custom assert
> function, and our arrays are protected, so if the interrupt routine
> goes out of bounds on the array, the assert will fire. We are in the
> process of writing a custom "print" function that can be used in
> interrupt context, but we only want it to work in interrupt context,
> otherwise we will use our normal messaging system.) This code performs
> that function. (Although it requires platform specific implementation
> in vectors.S, which I provided for i386.) I went ahead and put DSR
> tracking in also, although it is not as necessary for our application.
I don't really like this. It is even more overhead in the interrupt
path that we really don't want. Those increments are likely to cause
cache misses and make interrupt handling even slower.
There's no operational reason for eCos to need to keep track of this
stuff so I don't think it should be part of eCos. If you want to keep
track of interrupt or DSR calls, they can do this in application
code. Each ISR and DSR can increment/decrement the counters as
There are other ways of detecting whether you are in an ISR. For
example by comparing the address of a local variable with the range of
the interrupt stack.
What does your custom print do that diag_printf() cannot? I would
question any system design that required any kind of printing from
Of course you are free to make any changes to the HAL and the rest of
eCos in your own sources. However, I'm not happy about accepting this
back into the main sources.
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts