This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: why need to call Cyg_Scheduler::get_current_thread()->set_saved_context(regs) in interrupt_end()?
- From: Nick Garnett <nickg at ecoscentric dot com>
- To: Brij Bihari Pandey <fuzzhead012 at yahoo dot com>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: 04 Oct 2002 10:04:19 +0100
- Subject: Re: [ECOS] why need to call Cyg_Scheduler::get_current_thread()->set_saved_context(regs) in interrupt_end()?
- References: <20021003095945.50882.qmail@web21010.mail.yahoo.com>
Brij Bihari Pandey <fuzzhead012@yahoo.com> writes:
> Hi Nick,
>
> > We have options in some HALs to control exactly
> > which registers get saved in an interrupt and which
> > get saved in a context switch.
> > When these are enabled only caller-saved registers
> > are saved in the interrupt
> I don't understand this point. Every interrupt may not
> be a timer interrupt thus leading to context switch,
> hence the "entier CPU state ... distributed
> across....duplicated." is bit confusing to me.
Any interrupt can result in a context switch. Or not: you don't know
until the ISR and DSR have run.
>
> Otherwise too, I am not able to comprehend your
> interrupt related explanation above. What I understand
> in above explanations of yours, is that in interrupt
> state saving, only those registers will be saved that
> caller function saves before calling another function.
> right?
Correct.
>
> Since interrupt can come at any point of time if we
> don't save all the registers in interrupt, then how
> can we have the same state back after returning from
> interrupt???
>
> Won't other (callee saved) regs be corrupted? Or is
> it that the assembly code saves callee saved regs also
> (after saving interrupted CPU state) before calling
> any other interrupt handling routine?
>
The VSR only saves the caller-saved registers, and only uses those
registers for its own work. When it calls the ISR, the ISR will obey
the ABI and save/restore any callee-saved registers it uses. Similarly
with the call to interrupt_end().
HAL_THREAD_CONTEXT_SWITCH() also obeys the ABI. It is called as a
function so it knows that all the caller-saved registers will have
been saved before it is entered, so it only ever needs to save the
callee-saved registers.
So, a thread that has been preempted as a result of an interrupt will
have some of its state in the register set saved by the VSR and some
in the register set saved by the context switch.
--
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