[libdispatch-dev] Fwd: Race in dispatch_semaphore_wait(DISPATCH_TIME_NOW)

Dmitri Shubin sbn at tbricks.com
Thu May 22 02:09:33 PDT 2014


(forwarding to list)

Hi Dave,

On Wed, May 21, 2014 at 8:54 PM, Dave Zarzycki <zarzycki at apple.com> wrote:

>
> This is almost surely a bug in the port to these platforms. Apple’s
> operating system uses Mach to implement this feature, but Mach is not
> available on Linux and Solaris.
>

AFAIU libdispatch on OS X uses Mach semaphores instead of POSIX ones used
on Linux/Solaris. But the issue is irrelevant to OS semaphore
implementation.

Actually I tried to reproduce it on OS X using (named) POSIX semaphores but
failed.
I.e. the same (racy) code that hangs on Linux/Solaris doesn't hang on OS X.
I even tried simple semaphore implementation using mutex+condition variable
but again no luck on OS X.

My guess is that this is related to differences in thread scheduler
implementations on these OS'es.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/libdispatch-dev/attachments/20140522/e814743d/attachment.html>


More information about the libdispatch-dev mailing list