Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: munnari!cs.ua.oz.au!hugh@uunet.uu.net (Hugh Garsden) Newsgroups: comp.sys.sun Subject: SPARC Context Switching and Register Windows Keywords: Windows Message-ID: <777@brazos.Rice.edu> Date: 26 Jul 89 06:04:33 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 45 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 8, Issue 94, message 12 of 21 A few weeks ago there was some discussion about implementing light-weight processes (LWP's) on RISC machines. In particular, I have a routine for implementing context switching between LWP's on a SPARC machine, a SUN 4/280 running SunOS (thanks to Zalman Stern who posted some routines on which I have based my own). The routine goes like this - save register window flush all active windows (of LWP) to the stack save other global registers switch to a new stack load globals restore register window jump to a new thread Flushing the register windows does 2 important things - (1) saves context of out-going LWP on the stack (2) invalidates all previous windows so that when the incoming LWP executes a restore, the kernel restores the window from the stack, thus loading new context (at least I think this is what happens) To flush the register windows I execute this SPARC trap instruction - ta ST_FLUSH_WINDOWS All of this is working fine, but it is inefficient, because there are cases when the suspended LWP is not going to be restarted, so I don't always have to save context. What I want is this - a trap routine similar to ST_FLUSH_WINDOWS that gives me (2) above, but NOT (1). I know that there is a trap called ST_CLEAN_WINDOWS, but this doesn't seem to give me what I want. Something else that I would like to know, where in the SunOS manuals is there any documentation (and I mean DETAILS) about SunOS software traps? -------------------------------------- Hugh Garsden Dept. of Computer Science University of Adelaide G.P.O. Box 498 Adelaide 5001 Australia hugh@chook.ua.oz.au