From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 15 23:57:48 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85299106566B; Wed, 15 Aug 2012 23:57:48 +0000 (UTC) (envelope-from listlog2011@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 482178FC08; Wed, 15 Aug 2012 23:57:47 +0000 (UTC) Received: by pbbrp2 with SMTP id rp2so643339pbb.13 for ; Wed, 15 Aug 2012 16:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=xMSaRK81zGT+Sr8B9UNjBAZ3IJT08cA3n+PIizpJ3iQ=; b=E8A28oiQwyhuYWrKC8O/McU6PusUPQdK0Rqy6BOvX/o6xQe5lP49gLcl/+69Q6JpdU BdDjpZJIzmFM/4bMbc//xTU1gS36yx8cVkOV2WoSiir1FtkAH6LYhWyAlZuE5Okybdqt DctPE54T49iNH4WXaqCc7Yo3OraHgx5InlbaTO1/Puil2mAJtMHgMn01s/9nue0hsxKY B2EWAloIFeAj7tSB8miAj0bczaSlcy3hKlO0IYZ8QKND8iH4qFGkHHikCiSz47DCYHCE I0h0UXEFWtgkcQPAiSSEFe0Nd/FKTGchg1r6swqlY5Eo1F+/KlGXmY+xQlNit4p/WY3H vRSg== Received: by 10.68.132.194 with SMTP id ow2mr15325323pbb.36.1345075067088; Wed, 15 Aug 2012 16:57:47 -0700 (PDT) Received: from xp5k.my.domain ([115.192.132.92]) by mx.google.com with ESMTPS id rd7sm1349233pbc.70.2012.08.15.16.57.43 (version=SSLv3 cipher=OTHER); Wed, 15 Aug 2012 16:57:46 -0700 (PDT) Message-ID: <502C3775.8090401@gmail.com> Date: Thu, 16 Aug 2012 07:57:41 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120808 Thunderbird/13.0.1 MIME-Version: 1.0 To: Konstantin Belousov References: <20120730102408.GA19983@stack.nl> <20120730105303.GU2676@deviant.kiev.zoral.com.ua> <20120805215432.GA28704@stack.nl> <20120806082535.GI2676@deviant.kiev.zoral.com.ua> <20120809105648.GA79814@stack.nl> <5029D727.2090105@freebsd.org> <20120814081830.GA5883@deviant.kiev.zoral.com.ua> <502A1788.9090702@freebsd.org> <20120814094111.GB5883@deviant.kiev.zoral.com.ua> <502A6B7A.6070504@gmail.com> <20120815174609.GM5883@deviant.kiev.zoral.com.ua> In-Reply-To: <20120815174609.GM5883@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, davidxu@freebsd.org, Jilles Tjoelker Subject: Re: system() using vfork() or posix_spawn() and libthr X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: davidxu@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2012 23:57:48 -0000 On 2012/08/16 01:46, Konstantin Belousov wrote: > On Tue, Aug 14, 2012 at 11:15:06PM +0800, David Xu wrote: >> You are requiring the thread library to implement such a mutex >> and other locks, that after vfork(), the mutex and other lock types must >> still work across processes, the PTHREAD_PROCESS_PRIVATE type of >> mutex and other locks now need to work in a PTHREAD_PROCESS_SHARE >> mode. > In fact, yes. In my patch I achieve this by single-threading the parent, I still think single-threading is execussive, vfork should be fast, and because parent thread is already waiting for child process, there is no problem to reuse the parent's stack in child process, it is compatible. > which means that existing _PRIVATE mutexes are enough. Well, you forget that if private mutex sleep-wakeup queue is in kernel, you only can see it in same process, otherwise it is a security problem. Now It works because it is me implementing umtx in such a way that it comparings two vmspace pointers in kernel umtx code, and treat two threads are in same process if they are same. But there are implementations do not work in this way, they simply look up lwpid in same process, and if not found, the mutex is broken. process-private and proecess-shared locks work in very different way, then your assumptions is false.