From owner-freebsd-hackers Tue Sep 16 00:40:39 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id AAA29052 for hackers-outgoing; Tue, 16 Sep 1997 00:40:39 -0700 (PDT) Received: from alpo.whistle.com (alpo.whistle.com [207.76.204.38]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id AAA29031 for ; Tue, 16 Sep 1997 00:40:35 -0700 (PDT) Received: (from daemon@localhost) by alpo.whistle.com (8.8.5/8.8.5) id AAA28765; Tue, 16 Sep 1997 00:31:38 -0700 (PDT) Received: from current1.whistle.com(207.76.205.22) via SMTP by alpo.whistle.com, id smtpd028762; Tue Sep 16 07:31:30 1997 Date: Tue, 16 Sep 1997 00:30:50 -0700 (PDT) From: Julian Elischer To: Simon Shapiro cc: Jason Thorpe , freebsd-hackers@FreeBSD.ORG Subject: Re: What is wrong with this snipet? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Mon, 15 Sep 1997, Simon Shapiro wrote: > > Hi Jason Thorpe; On 14-Sep-97 you wrote: > > On Sat, 13 Sep 1997 16:34:42 -0700 (PDT) > > Simon Shapiro wrote: > > > > > Why would the following segfault on 6 of the 10 iterations? > > > > In the FreeBSD implementation of RFMEM (which does not match Plan 9's), > > the child gets the same stack as the parent. If you "return" in the > > child, > > someone's stack gets munched. > > Not exactly useful, I'd say... I beg to dissagree. it does exactly what it says it does.. "Share entire address space" How are you going to share address spaces if you don't share the stack.. last time I looked the stack was a part of the address space. The aim of this is the same as the Linux CLONE() call. The processes with shared address spaces look to all the world the same as two threads in the same process. Obviously, multiple threads in the same process can see each other's stacks etc, and various 'threads' in a process can 'migrate' to the other process if all shared processes can see all the stacks.. The secret is to allocate a new stack before the rfork() for the child, and make sure that it does a longjmp() to it the moment that it returns, leaving the stack uncorrupted for the returning parent. Usually this is all hidden inside a library routine called thread_fork() or similar. rfork() just supplies the mechanism. julian > > --- > > > Sincerely Yours, (Sent on 15-Sep-97, 21:20:55 > by XF-Mail) > > Simon Shapiro Atlas Telecom > Senior Architect 14355 SW Allen Blvd., Suite 130 Beaverton OR 97005 > Shimon@i-Connect.Net Voice: 503.643.5559, Emergency: 503.799.2313 >