This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Question about Stack usage in eCOS ? Thanks
- From: Nick Garnett <nickg at ecoscentric dot com>
- To: "Qiang Huang" <jameshq at liverpool dot ac dot uk>
- Cc: <ecos-discuss at sources dot redhat dot com>
- Date: 23 Sep 2002 18:28:51 +0100
- Subject: Re: [ECOS] Question about Stack usage in eCOS ? Thanks
- References: <BDEPKKELILOKGOAOMONOOEBJCAAA.jameshq@liv.ac.uk>
"Qiang Huang" <jameshq@liverpool.ac.uk> writes:
> Hi:
>
> Q1:
> I just wonder the exact meaning of using a seperate stack for interrupt
> handling? Is that mean: all the interrupts handling will be in its own stack
> rather than the user thread's stack? (Is this correct for all targets?)
Yes.
>
> Q2:
> Is the thread context switching happens after **exiting**(?) the clock
> ISR and uses the old thread's stack rather than the interrupt handler's
> stack? (Is this correct for all targets?)
>
Yes.
It is not essential that a HAL implements the interrupt stack and
those that do have a configuration option
(CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK) to control whether
it is enabled. If a HAL does not implement the interrupt stack, then
thread stacks must be large enough to accommodate all ISRs and DSRs
that might be called.
> Q3:
> Is the following correct or not?(My assumption)
>
> (Uses seperate interrupt stack)
>
> 1). The hightest avaliable Thread (thread_A) get excuted by
> HAL_THREAD_LOAD_CONTEXT() (so on thread_A's stack correct??)
> --> 2). clock interrupt (Enter ISR and uses the Interrupt's stack correct??)
> --> 3). Exit from clock ISR (stack for interrupt handling will be unwinded
> back correct??)then stack switch back to thread_A's stack correct??
So far so good.
> --> 4). DSR invoked (now uses thread_A's stack correct??)
> --> 5). rtc->tick() invoked ( on thread_A's stack correct??)
If the HAL implements an interrupt stack, then the DSR will be
executed on that. See the diagram I posted for the exact set of steps.
> --> 6). HAL_THREAD_SWITCH_CONTEXT() invoked ( so up to this point the
> thread context for thread_A will be saved to thread_A's stack right (does
> this includes??) and thread_B's thread context get restored from thrad_B's
> stack right??
> --> 7). branch to the thread_B's execution context.
>
Correct.
--
Nick Garnett - eCos Kernel Architect
http://www.eCosCentric.com/
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss