[ECOS] Determining current context

Nick Garnett nickg@ecoscentric.com
Tue May 27 12:02:00 GMT 2003

David Brennan <eCos@brennanhome.cxm> writes:

> That was the impression that I got from the sample code.  However, I
> have a generic function which I would like to be able to call from any
> context, but it must behave slightly differently in interrupt context. 
> I was hoping that there was an operating system call of some sort which
> could tell me.  (Obviously it must know the current context).

eCos does not need to keep track of the current context. It is
implicit in the code that is running, there are no routines that
change their beviour depending on this. Generally, code puts itself
into the right state by disabling interrupts or locking the scheduler.

Really, the ISR vs DSR vs thread context stuff was a fiction invented
to make things easier to describe in the documentation. There is no
explicit representation of these in the code.

> I'd even
> settle for something as crazy as checking to see if the current stack
> area is the isr area.

That won't work because both ISRs and DSRs are executed on the
interrupt stack. Better is to just pass the function an argument
indicating where it was called from.

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

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

More information about the Ecos-discuss mailing list