From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 23 17:18:05 2009 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 A46AE106566B; Fri, 23 Oct 2009 17:18:05 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 401DB8FC1A; Fri, 23 Oct 2009 17:18:04 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.3/8.14.3/NETPLEX) with ESMTP id n9NHI2TG008879; Fri, 23 Oct 2009 13:18:02 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.2 (mail.netplex.net [204.213.176.10]); Fri, 23 Oct 2009 13:18:03 -0400 (EDT) Date: Fri, 23 Oct 2009 13:18:02 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Andrew Gallatin In-Reply-To: <4AE1D97F.6060708@cs.duke.edu> Message-ID: References: <4AE0BBAB.3040807@cs.duke.edu> <4AE0C995.5060303@cs.duke.edu> <200910230802.49873.jhb@freebsd.org> <4AE1CE31.1090206@cs.duke.edu> <4AE1D1D2.1090307@cs.duke.edu> <4AE1D97F.6060708@cs.duke.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org, Christian Bell Subject: Re: semaphores between processes X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Oct 2009 17:18:05 -0000 On Fri, 23 Oct 2009, Andrew Gallatin wrote: > Daniel Eischen wrote: > >> >> We already use umtx. This really is a hack and I wouldn't >> advocate it. I'm not sure how you could make it work and >> not break existing ability to return appropriate error >> codes without slowing down the path in the non-shared >> case. You'd have to check to see if the address space >> was shared or not, which would require a system call. > > I'm probably missing something. What does it matter if the > address space is shared, as long as the umtx struct is > in shared memory? > > From my quick read, the umtx operations use a lock word > in userspace. For uncontested locks, they use atomic > ops to flip an id into the lock word. The kernel takes > over for contested locks, and does sleeping, wakup, etc. > Is this correct? Is there something here that matters > if the address space (and not just the lock word) is > shared? > >> All our public pthread_foo() symbols are weak. You >> can easily override them in your application code in >> the #ifdef freebsd case. What is wrong with providing >> your own library that overrides them to do what you >> require - this shouldn't change your application code? >> > > For our code, I was thinking of something like: > > #ifdef FreeBSD > #define lock(x) umtx_lock(x, getpid()) > #define unlock(x) umtx_unlock(x, getpid()) > #else > #define lock(x) pthread_mutex_lock(x) > #define unlock(x) pthread_mutex_lock(x) > #endif > > > I should probably just shut up and try it.. My apologies - I thought you were talking about changing our pthread_mutex_* functions in src/lib/... -- DE