Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 5 Mar 2016 19:14:34 -0500
From: Pedro Giffuni <pfg@...eBSD.org>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com
Subject: Re: FreeBSD's Google Summer of Code 2016



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]:

https://www.freebsd.org/doc/en/books/arch-handbook/locking.html

Cheers,

Pedro.

[1] You can watch the manpages here:
https://www.freebsd.org/cgi/man.cgi

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.