Longjmping back, and back again; Coroutines in C

Felix Lee flee at shire.cs.psu.edu
Tue Nov 21 23:09:38 AEST 1989


Jerker W}gberg <jerker at helios.se> wrote:
> The idea is that instead of actually switching stacks, I use the
> "real" stack but swap it in and out of malloced memory.
> 1. Can somebody explain why this fails on a SUN4.

The Sun-4 has a curious hack known as register windows.  Rather than
putting things on the stack, it keeps everything in registers.  Each
subroutine gets its own set of 24 registers called a register window.
For passing arguments, register windows overlap: 8 output registers in
your window become input registers when you call another subroutine.

Space is reserved on the stack for saving all the register windows,
but they aren't written out until necessary.  A Sun-4 might have, say,
half a dozen register windows, which comes to 96 registers.  Flushing
all the registers to memory is normally done by the kernel, whenever a
context switch occurs, or when you run out of register windows.

There's (undocumented?) kernel traps to save/restore your register
windows that I can't seem to find right now.
--
Felix Lee	flee at shire.cs.psu.edu	*!psuvax1!flee



More information about the Comp.lang.c mailing list