From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <79a03ecc1c3386985559c25f009f1d95@swtch.com> To: matthiasb@acm.org, 9fans@cse.psu.edu Subject: Re: [9fans] amd64 support in p9p? From: "Russ Cox" Date: Thu, 2 Mar 2006 18:27:23 -0500 In-Reply-To: <20060302231511.GA11050@pestilenz.org> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Cc: Topicbox-Message-UUID: 0a70be4c-ead1-11e9-9d60-3106f5b1d025 > is there anybody interested in helping to port the > plan9 from user space to amd64/x86_64? > The most platform dependend code seems to be the libthread > stuff. On OpenBSD-amd64 I can borrow an assembler version of > rfork_thread from the OpenBSD librthread and can improvise > the _tas function. The get/setmcontext pose a problem because > I do not know if struct ucontext must really be exactly the same > as struct sigcontext. Which operating system are we talking about? If the operating system provides: - a pthreads that doesn't use the high bits of the stack pointer as the per-pthread register - working makecontext, getcontext, setcontext then all you have to write is a _tas function, and on the x86_64 you should just use the 386 one unmodified (see Linux-386-asm.s) If the OS does not provide a working makecontext, getcontext, and setcontext, then you need to write those too. They needn't follow any structures laid down by the rest of the system. They just have to match each other. For example, power-ucontext.h is just made up from scratch. It just needs to be a register set and match the assembly. If the OS does not provide a pthreads with a real per-thread register then you are in bigger trouble and have to provide an entire kernel thread implementation. I doubt very much you need to do this on any x86-64. The only people who made this mistake seem to be the early implementers of 386 thread libraries (these broken libraries are still in use on NetBSD, OpenBSD, and Linux pre-NPTL), and that's necessitated by the small number of registers. On x86-64, there's no reason to make that mistake. In short, you probably don't need to write rfork_thread, you might need to write getcontext/setcontext, and you can just steal _tas. Russ