This is the mail archive of the ecos-discuss@sources.redhat.com 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: Why Just even registers get saved during register windows under/over flow in Sparc? Thanks.


<delurk>

Gary Thomas <gthomas@ecoscentric.com> writes:
> Date: 13 Aug 2002 07:14:51 -0600
> Message-Id: <1029244491.8797.323.camel@hermes.chez-thomas.org>
> 
> On Tue, 2002-08-13 at 06:24, Qiang Huang wrote:
> > Hi all:
> >    In the overflow/underflow handler in Sparc why just a single register
> > window(Isn't that all the register windows get saved to stack?) get saved
> > and why just even register get saved? Thanks a lot.
> 
> A Nick indicated yesterday, the entire window set is saved
> when a thread switch occurs.  Other than that, it makes sense
> to only bother with a single window when an under/overflow
> happens.

Correct.  For each underflow or overflow, exactly one window is saved or
restored in the trampoline code, because that is all you need to do.
Saving more windows would be a waste of time.  Trampoline code is the
initial trap handler that decodes "by hand" these exceptions and handles
them immediately, for efficiency.

When switching threads, like *all* eCos ports, the same code is used
whether switching due to an interrupt or when switching due to a kernel
call.  It's the final scheduler-unlock back to zero that does it.  In the
interrupt case this is called within interrupt-end, and the task is
suspended in that C-stack calling context.

IIRC, on the SPARClite, the save of the entire set of registers is
performed by simply going "save" 6 times then "restore" 6 times (for a
machine with 8 register windows).  This is in the context-switch code,
separate from the interrupt handling and trap handling.  It will use the
trampoline code to ensure any dirty windows out to the task's stack memory,
just like any other save would, and if there are no dirty windows, it will
cost almost no time.

When restoring a thread context, only one window is loaded.  Loading any
more might be a waste of time, depending what the thread will do next.

Note that I'm talking about SPARClite here; IIRC, the NIOS thingy that's a
bit like a SPARC was rather broken in that area, and you would be forced to
save and restore all register windows at once, because it didn't implement
the proper control register for making underflow and overflow traps: you
get a trap if you pop up from window 0 or if you push down from window 5,
and that's that.  Useless POS.  (My personal opinions and vague
recollections alone).

> As for "even registers only"; look more closely.  The registers
> are being saved as even/odd register pairs.  For example, the
> instruction (std %l0,[%sp+0]) saves registers %l0 and %l1 in
> a single instruction.  Much faster.

Absolutely right; std is store *double*.  Even though they're integer
registers.

HTH,
	- Huge

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


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