This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: ISR not causing an DSR in some rare conditions


Gary Thomas <gary@mlbassoc.com> writes:

> On Mon, 2006-01-23 at 15:08 -0800, Jay Foster wrote:
> > It seems troubling to me that the context switching code does not save and
> > restore all registers.  Any register(s) not saved and restored by the
> > context switching code could not be used anywhere, since you would never
> > know when a context switch occurred, clobbering the registers.  I agree that
> > from the point of view of the ARM ABI this is acceptable, since you know
> > when you called another function, but this is not so for context switches.
> > I suspect that there is something else going on here, of which I am
> > ignorant.
> > 
> 
> It's not as bad as you think.  "User" code does not call the context
> switch code directly - you can only get here by passing through the
> kernel, in particular via the scheduler.  When this thread runs 
> again, it will unwind through the kernel to wherever it was and all
> pertinent registers will be restored.

To expand on this: The important fact is that the context switch
routine is accessed via a call which obeys the ARM ABI. So we know
that any registers that the ABI defines as not being preserved across
a call do not need to be saved. Either the caller has avoided using
them, or has already arranged to save them. On the ARM these include
the argument registers and some registers defined as
temporaries. While this number is small on the ARM, in other
architectures, like MIPS and PowerPC, not saving these registers can
make a big difference.

> 
> The code paths that do matter, namely exception and interrupt 
> processing, can [and do] save everything as they can happen anywhere.
>

In fact exception and interrupt VSRs need only save those registers
that are not saved by the context switch code. We can rely on the
calling conventions to save and restore any other registers. Thus an
exception/interrupt context plus a thread switch context will save the
whole state. There are some registers (SP, PC, FP and so on) which
need saving in both places, but the overlap is usually small.

-- 
Nick Garnett                                          eCos Kernel Architect
http://www.ecoscentric.com                     The eCos and RedBoot experts
Besuchen Sie uns vom 14.-16.02.06 auf der Embedded World 2006, Stand 11-222
Visit us at Embedded World 2006, NÃrnberg, Germany, 14-16 Feb, Stand 11-222


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]