From owner-freebsd-hackers Tue Sep 16 01:58:48 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id BAA12662 for hackers-outgoing; Tue, 16 Sep 1997 01:58:48 -0700 (PDT) Received: from dyson.iquest.net (dyson.iquest.net [198.70.144.127]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id BAA12642; Tue, 16 Sep 1997 01:58:40 -0700 (PDT) Received: (from root@localhost) by dyson.iquest.net (8.8.6/8.8.5) id DAA00240; Tue, 16 Sep 1997 03:58:33 -0500 (EST) From: "John S. Dyson" Message-Id: <199709160858.DAA00240@dyson.iquest.net> Subject: Re: What is wrong with this snipet? In-Reply-To: <199709160835.KAA04626@ocean.campus.luth.se> from Mikael Karpberg at "Sep 16, 97 10:35:49 am" To: karpen@ocean.campus.luth.se (Mikael Karpberg) Date: Tue, 16 Sep 1997 03:58:33 -0500 (EST) Cc: dyson@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Reply-To: dyson@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Mikael Karpberg said: > > This is kinda interesting. You can't move forward or backwards in the > stack, which means you can't call functions or return from functions. > You can possibly calculate two values at the same time, withing the same > function, without calling another function. This doesn't seem overly > useful, however. > > What am I missing? Could you make a short example of a use for this? > 1) Have a new stack ready 2) Push the address of the start of the thread onto the new stack. 3) call rfork with RFMEM and other flags. 4a) In the child, immediately set the stack pointer to the new one that was prepared in the parent. Issue a return instruction. 4b) In the parent, continue on. The key to this working is to avoid dependence on the stack in the child until the new stack pointer is loaded. The only problem that I can see, is the possibility of a signal being issued while the child is temporarily using (and avoiding actual use of) the parent's stack. That problem is evil, but there are a couple of workarounds for it (specifically, there is another rfork bit that says that it is a thread creation.) We can hold signals until the child thread is ready to accept them. I suspect that the thread creation bit will be used to hold signal delivery in the child, and the child will have to explicitly enable delivery. This will generally be transparent to the user (unless the user will be writing their own thread support code.) -- John dyson@freebsd.org jdyson@nc.com