Threading Question

Sean Kelly sean at invisibleduck.org
Tue Oct 30 11:04:25 PDT 2012


On Oct 25, 2012, at 11:18 PM, Jacob Carlborg <doob at me.com> wrote:

> On 2012-10-26 01:18, Sean Kelly wrote:
>> On Oct 25, 2012, at 4:12 PM, Alex Rønne Petersen <alex at lycus.org> wrote:
>>> 
>>> What's used on OS X? I forget...
>> 
>> The method used is similar to how GC works on Windows--there's a kernel call that can be used to explicitly suspend a thread.  I can't remember the function name offhand though.
> 
> The Posix functions weren't working properly?

The semaphore implementation for OSX is not signal-safe.  Originally, druntime used the signal approach on OSX and had deadlock issues in the signal handler (OSX semaphores wrap a global mutex to obtain something from a shared pool).  Also, semaphores on OSX are just ridiculously slow.  The current method for suspending and scanning threads on OSX is much faster.  I wish Posix in general had the same feature.  Using signals is really a hack.

It may be worth dropping use of SIGUSR1/2 in favor of the realtime signals as well, since SIGUSR1/2 are in pretty common use.


More information about the Digitalmars-d-learn mailing list