From owner-freebsd-current Wed Dec 10 17:27:49 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id RAA14461 for current-outgoing; Wed, 10 Dec 1997 17:27:49 -0800 (PST) (envelope-from owner-freebsd-current) 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 RAA14439 for ; Wed, 10 Dec 1997 17:27:29 -0800 (PST) (envelope-from toor@dyson.iquest.net) Received: (from root@localhost) by dyson.iquest.net (8.8.8/8.8.8) id UAA01339; Wed, 10 Dec 1997 20:27:20 -0500 (EST) (envelope-from toor) From: "John S. Dyson" Message-Id: <199712110127.UAA01339@dyson.iquest.net> Subject: Re: FreeBSD 3.0-current(12/10): rfork() problems in USERLAND? In-Reply-To: from Curtis Bray at "Dec 10, 97 03:40:09 pm" To: cbray@best.com (Curtis Bray) Date: Wed, 10 Dec 1997 20:27:20 -0500 (EST) Cc: freebsd-current@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-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Curtis Bray said: > Hey Folks, > > I'm curious if anyone else if seeing this behavior with rfork... I've > cvsup'ed to the latest code as of 12/10 and I'm still having difficulties > with rfork(RFPROC | RFMEM) out in userland. > > From past discussions my understanding was John Dyson had added the > RFMEM support into current as part of the kernel thread support for the > AIO stuff, but I'm unclear if the user process support has been finished. > Anyway, here's a dump of the program I'm running (very very basic) and > the output that occurs. The core file was truncated when I tried to look > at it with gdb. > You cannot use rfork() the way that you are. Take a look at the rf.S following this email. Our rfork() pushes as much into userland as possible. -- John dyson@freebsd.org jdyson@nc.com .file "rf.S" #include #include "DEFS.h" #include "SYS.h" #define KERNEL #include #undef KERNEL #undef DEBUG /* * 8 12 16 20 24 28 * _rfork(flags, stack, startrtn, startarg, userrtn, arg); * * flags: RF* flags for rfork in unistd.h. * subr: subroutine to run as a thread. * stack: top of stack for thread. * arg: argument to thread. */ .stabs "rf.S",100,0,0,Ltext0 .text Ltext0: .type _thrfork,@function .stabd 68,0,1 ENTRY(thrfork) pushl %ebp movl %esp, %ebp pushl %esi /* * Push thread info onto the new thread's stack */ movl 12(%ebp), %esi / get stack addr subl $4, %esi movl 28(%ebp), %eax / get user argument movl %eax, (%esi) subl $4, %esi movl 24(%ebp), %eax / get user thread address movl %eax, (%esi) subl $4, %esi movl 20(%ebp), %eax / get internal argument movl %eax, (%esi) subl $4, %esi movl 16(%ebp), %eax / get internal subroutine movl %eax, (%esi) .stabd 68,0,2 /* * Prepare and execute rfork */ pushl 8(%ebp) pushl %esi leal SYS_rfork, %eax KERNCALL jb 2f .stabd 68,0,3 /* * Check to see if we are in the parent or child */ cmpl $0, %edx jnz 1f addl $8, %esp popl %esi movl %ebp, %esp popl %ebp ret .p2align 2 /* * If we are in the child (new thread), then * set-up the call to the internal subroutine. If it * returns, then call __exit. */ .stabd 68,0,4 1: movl %esi,%esp #ifdef DEBUG movl %esp, _stackaddr movl (%esp), %eax movl %eax, _stack movl 4(%esp), %eax movl %eax,_stack+4 movl 8(%esp), %eax movl %eax,_stack+8 movl 12(%esp), %eax movl %eax,_stack+12 #endif popl %eax #ifdef DEBUG movl %eax,_fcn #endif call %eax addl $12, %esp /* * Exit system call */ pushl %eax pushl $SYS_exit call _syscall .stabd 68,0,5 2: movl $EAGAIN, _errno movl $-1, %eax leave ret .stabs "thrfork:f67",36,0,6,_thrfork Lfe1: .size _thrfork,Lfe1-_thrfork #ifdef DEBUG .data .globl _stack _stack: .long 0 .long 0 .long 0 .long 0 .long 0 .globl _stackaddr _stackaddr: .long 0 .globl _fcn _fcn: .long 0 #endif