Path: utzoo!attcan!uunet!dino!ux1.cso.uiuc.edu!uwm.edu!wuarchive!psuvax1!news From: flee@shire.cs.psu.edu (Felix Lee) Newsgroups: comp.lang.c Subject: Re: Longjmping back, and back again; Coroutines in C Message-ID: <1989Nov21.120938.9200@psuvax1.cs.psu.edu> Date: 21 Nov 89 12:09:38 GMT References: <457@enea.se> Sender: news@psuvax1.cs.psu.edu Organization: Penn State University Computer Science Lines: 21 Jerker W}gberg 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@shire.cs.psu.edu *!psuvax1!flee