From owner-freebsd-current@FreeBSD.ORG Tue Jan 24 05:38:57 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB86A16A41F; Tue, 24 Jan 2006 05:38:57 +0000 (GMT) (envelope-from julian@elischer.org) Received: from a50.ironport.com (a50.ironport.com [63.251.108.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8FA7B43D48; Tue, 24 Jan 2006 05:38:57 +0000 (GMT) (envelope-from julian@elischer.org) Received: from unknown (HELO [192.168.2.4]) ([10.251.60.33]) by a50.ironport.com with ESMTP; 23 Jan 2006 21:38:56 -0800 X-IronPort-Anti-Spam-Filtered: true Message-ID: <43D5BD70.6080503@elischer.org> Date: Mon, 23 Jan 2006 21:38:56 -0800 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.11) Gecko/20050727 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: Peter Jeremy , freebsd-current@freebsd.org Subject: Re: kernel thread as real threads.. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jan 2006 05:38:57 -0000 Daniel Eischen wrote: >On Tue, 24 Jan 2006, Peter Jeremy wrote: > > > >>On Mon, 2006-Jan-23 20:38:46 -0500, Daniel Eischen wrote: >> >> >>>On Tue, 24 Jan 2006, Peter Jeremy wrote: >>> >>> >>> >>>>On Mon, 2006-Jan-23 19:59:02 -0500, Daniel Eischen wrote: >>>> >>>> >>>>>POSIX specifies that only 1 thread (the forking thread) is present >>>>>after a fork. >>>>> >>>>> >>>>Just to clarify, I presume you are talking about only one thread >>>>existing in the child process and the parent's threads still exist as >>>>they did before the fork(). If fork() arbitrarily killed all the >>>>threads in the parent process, that would be a real PITA. >>>> >>>> >>>Correct, I assumed we were talking about the child process. >>> >>> >>My understanding of Robert's issue was the case where a parent has >>multiple threads, one thread does a fork() whilst the remaining >>threads are not blocked. If the remaining threads are executing >>whilst fork() is copying the process address space, then the child >>will could inherit a confused (partially indeterminate) copy of the >>parent's address space, depending on what the other threads have >>been doing. >> >> > >I think that's OK. The only thing that is guaranteed safe (in the >child) after a fork from a multi-threaded process are the >async-signal-safe functions. If a process has aio active, >it shouldn't assume anything about the childs state after a >fork. I think it's only important that the forking thread >continues on normally in the child. OTOH, if there is a >possibility of some inconsistent kernel state that will affect >the child if it calls any of the async-signal-safe functions >or one of the exec() functions, that should be avoided. > > It's not a case of kernel state so much as the state of user space. Of course there is some course kernel state involved, such as if one thread does a fork while the other is mmaping pages or setting signals.