From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 23 16:07:57 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 60A571065692; Fri, 23 Oct 2009 16:07:57 +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 EF9878FC20; Fri, 23 Oct 2009 16:07:56 +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 n9NG7sSS029357; Fri, 23 Oct 2009 12:07:54 -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 12:07:54 -0400 (EDT) Date: Fri, 23 Oct 2009 12:07:54 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Andrew Gallatin In-Reply-To: <4AE1D1D2.1090307@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> 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 16:07:57 -0000 On Fri, 23 Oct 2009, Andrew Gallatin wrote: > Daniel Eischen wrote: >> On Fri, 23 Oct 2009, Andrew Gallatin wrote: >> >>> It would be great if they were, but that discussion was 6 months >>> ago, and nothing seems to have happened. Plus we need to support >>> at least 7.X and probably 6, so any changes here might not even >>> help us. >>> >>> What is wrong with just using umtx directly? It seems to do >>> exactly what we need. >> >> Because you can't do anything more than use umtx directly, >> like check for mutex types and return appropriate error >> codes. Just look at other implementations - Solaris, >> Linux, all have their pthread_*_t as public structs. > > I'm not saying that having pthread*t public, and getting all > the features of real PTHREAD_PROCESS_SHARED would not be far > better in general. But in this case all we need is a lock around > a shared resource. Eg, nothing fance. So our choices seem to be > either: > > 1) use sysv semaphores (ick) > 2) use a hand rolled spinlock (ick) > 3) use some sort of hack built into our driver (ick, ick) > 4) use umtx > > Is there some bug or limitation in umtx that makes it inappropriate? > (beyond the obvious, like the potential to leave a resource locked > forever if the lock holder exits). 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. 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? -- DE