From owner-freebsd-arch@FreeBSD.ORG Tue May 6 07:13:51 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C2BC637B401 for ; Tue, 6 May 2003 07:13:51 -0700 (PDT) Received: from park.rambler.ru (park.rambler.ru [81.19.64.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5977D43FBD for ; Tue, 6 May 2003 07:13:50 -0700 (PDT) (envelope-from is@rambler-co.ru) Received: from is.park.rambler.ru (is.park.rambler.ru [81.19.64.102]) by park.rambler.ru (8.12.6/8.12.6) with ESMTP id h46EDmmF084433; Tue, 6 May 2003 18:13:48 +0400 (MSD) Date: Tue, 6 May 2003 18:13:48 +0400 (MSD) From: Igor Sysoev X-Sender: is@is To: Terry Lambert In-Reply-To: <3EB72C95.6E9EEA50@mindspring.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-arch@freebsd.org Subject: Re: rfork(RFPROC|RFMEM) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2003 14:13:52 -0000 On Mon, 5 May 2003, Terry Lambert wrote: > Igor Sysoev wrote: > > On Mon, 5 May 2003, Terry Lambert wrote: > > What is stack glue ? > > See the code in fork1() in /sys/kern/kern_fork.c. I do not see any stack manipulation in kern_fork.c except the creating alternate kstack for KSE thread in 5.0. And rfork(2) can not create such stack - it passes 0 to fork1(). In 4.x there's no stack code at all. > > I use rfork_thread(3) wrapper that allows to setup another stack for > > rfork()ed process. By the way I found the bug in x86 rfork_thread(3)'s error handling: --- /usr/src/lib/libc/i386/gen/rfork_thread.S Wed Feb 7 03:12:45 2001 +++ /usr/src/lib/libc/i386/gen/rfork_thread.S Tue May 6 17:45:14 2003 @@ -108,5 +108,8 @@ * Branch here if the thread creation fails: */ 2: + popl %esi + movl %ebp, %esp + popl %ebp PIC_PROLOGUE jmp PIC_PLT(HIDENAME(cerror)) > > What RFTHREAD flag does ? > > See the code. It basically sets up for kernel threading, rather > than merely for processes sharing the same address space and/or > file descriptor table and/or heap, which is what rfork was > intended to be able to do. It also ensures propagation of any > SIGKILL to all peers, so they die all at once, in exit1() in > /sys/kern/kern_exit.c. It seems that the single purpose of the RFTHREAD flag is to kill peers when the leader got SIGKILL. And in 4.8-STABLE and 5.0-CURRENT (after 5.0-RELEASE) the leader also holds P_ADVLOCK flag. > > By the way linuxthreads port always uses RFTHREAD flag. > > They don't know any other way than the moral equivalent of > the Linux "clone" system call, so that's what they use; it's > technically not necessary. See also the source code in the Now it's necessary. Otherwise rfork() returns EINVAL. > directory /usr/src/lib/libpthread, which doesn't use rfork() > at all. I know it. Igor Sysoev http://sysoev.ru/en/