[libdispatch-dev] [PATCH] use libkqueue if sys/event.h is missing

Robert Watson robert at fledge.watson.org
Sun Nov 1 04:40:22 PST 2009


On Sun, 1 Nov 2009, Paolo Bonzini wrote:

>> Are you able to get basic test programs running with libdispatch and 
>> libkqueue on Linux now?
>
> You need my sem_t patch for that.

I think, FWIW, that both you and Kevin are right: it can be race-free on 
FreeBSD, but that it isn't currently.  Joakim's suggestion of simply 
allocating semaphores unconditionally for now seems like the best short-term 
path forward.  This shouldn't be particularly expensive: POSIX semaphores 
allocated by sem_init(3) without the pshared flag should be process-local and 
not rely on system calls (other than occasional requests to back malloc(3) 
with VM).  Glancing at the FreeBSD implementation, this certainly seems to be 
true -- for process-local semaphores, it uses the same umtx sleep/wakeup/etc 
bits used for pthread mutexes.  And it's certainly more portable...

Robert



More information about the libdispatch-dev mailing list