From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9494 Path: news.gmane.org!not-for-mail From: Pedro Giffuni Newsgroups: gmane.linux.lib.musl.general Subject: Re: FreeBSD's Google Summer of Code 2016 Date: Sat, 5 Mar 2016 19:59:35 -0500 Message-ID: <56DB80F7.8030700@FreeBSD.org> References: <56DB3D70.8010601@FreeBSD.org> <20160305212517.GK9349@brightrain.aerifal.cx> <56DB6095.4060204@FreeBSD.org> <20160305233254.GL9349@brightrain.aerifal.cx> <56DB766A.3050500@FreeBSD.org> <20160306002547.GM9349@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1457225950 10655 80.91.229.3 (6 Mar 2016 00:59:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Mar 2016 00:59:10 +0000 (UTC) Cc: musl@lists.openwall.com To: Rich Felker Original-X-From: musl-return-9507-gllmg-musl=m.gmane.org@lists.openwall.com Sun Mar 06 01:59:05 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1acN2C-0007ft-H7 for gllmg-musl@m.gmane.org; Sun, 06 Mar 2016 01:59:00 +0100 Original-Received: (qmail 5798 invoked by uid 550); 6 Mar 2016 00:58:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 5776 invoked from network); 6 Mar 2016 00:58:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1457225926; bh=Cx/CHXCSOi3I6j/roY1xqhnfCgacl2izxioMmNnHQoA=; h=Subject:To:References:Cc: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illa/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <20160306002547.GM9349@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:9494 Archived-At: On 03/05/16 19:25, Rich Felker wrote: > On Sat, Mar 05, 2016 at 07:14:34PM -0500, Pedro Giffuni wrote: >> >> >> On 03/05/16 18:32, Rich Felker wrote: >>> On Sat, Mar 05, 2016 at 05:41:25PM -0500, Pedro Giffuni wrote: >>>> First of all, great to hear there is interest on the musl side too. >>>> >>>> I think the biggest precedent of porting linux-oriented C libraries >>>> came from Debian's kFreeBSD. We accomodated a little by for them >>>> by defining __FreeBSD_kernel__ in sys/param.h. >>>> >>>> While using the optional linux-abi futex in FreeBSD could be an option, >>>> it is not really the cleanest option. The Debian guys did a port of >>>> NPTL using regular pthreads: >>>> >> >> Of course I ahould have meant "based on regular FreeBSD kernel services". >> >>>> http://thread.gmane.org/gmane.linux.debian.ports.bsd/11702 >>>> >>>> I am certain this will require more research but it would be useful >>>> for other ports as well. >>> >> >> We could ask Petr Salinger for the details, but I am pretty sure >> FreeBSD has the required functionality natively. >> >>> Glibc/NPTL has a lot of what I'd call "gratuitous abstraction" (like >>> the lll stuff) in their pthread primitives which makes this >>> "possible". I call it gratuitous because it's really really hard to >>> achieve correct implementations of the pthread sync primitives that >>> don't have serious corner-case bugs, and it's unlikely that their >>> abstractions actually suffice to make correct alternate >>> implementations. >>> >>> musl does not have any such abstraction. We require a compare-and-swap >>> operation or equivalent on which arbitrary atomic operations can be >>> constructed, a futex or equivalent operation that's roughly >>> while(*addr==expected) sleep(), and implement all the sync primitives >>> just once on top of these. >>> >> >> I am not a threading expert (or even a CS guy), but it sounds like >> mutex(9) with condvar(9) would do [1]: > > No, they don't satisfy the needs of musl; they have their own > additional storage requirements and are probably not AS-safe. It might > be possible to use them to implement a userspace-emulated futex queue > (only if they are AS-safe), but I don't see a way to extend that to > the process-shared case. > OK, it looks like sema(9) may be nearer (and also simpler but slower). For the process-shared case libthr(2) uses the stuff in sys/utmx.h, shich should be looked at but it is not documented[1]. Luckily Ed, the developer that would be mentoring the project, knows this stuff better than I do. Pedro. [1] http://fxr.watson.org/fxr/source/sys/umtx.h?v=FREEBSD8