Re: Has pthreads become antiquated?



Maxim Yegorushkin wrote:
Joe Seigh wrote:

I'm trying yet again to design an async safe function
because unix has signals which are still being designed
into new api's. There's only one async safe pthread
function and that's sem_post which is probably not the
most useful synchronization function around. Plus it's
not implemented in OSX. Well, it is but only to tell
you by return code that it's not implemented. While
that's not entirely stupid, it is very high up my List
of Stupid.

So I'll probably have to go with platform specific
solutions like futex on Linux and I don't know what
yet on OSX.


What is wrong with the idiomatic solution when you do nothing but write
a byte to a pipe/socketpair in the signal handler?


It's very limited. You can't really share data between signal handlers
and threads. And you're limited with what you can do with sig_atomic_t
and the thread that the signal handler runs on (sig_atomic_t having no
meaning w.r.t. the other threads). And if you restrict signals to
specific threads so you can use sig_atomic_t, you lose some of the advantages
of being able to dispatch a signal on any thread enabled for those signals.

Since unix signals aren't going away and more people will start to realize
that synchronizing data with signal handlers is problematic and that posix
offers no solutions, solutions will be developed outside of posix increasing
the marginalization of posix.

Though to be fair to posix threads, if condition variables were like signals,
condvars would be predefined and there would only be two of them for use by
an application.

--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software. .



Relevant Pages

  • Re: Using SetConsoleCtrlHandler
    ... "bare minimum" principal should work even in multithreaded POSIX apps, ... you rely on recursive lock acqusition in your "signal handler" - hard to ... POSIX signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Using SetConsoleCtrlHandler
    ... POSIX signals to POSIX processes". ... void handler { ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Browser survey
    ... any signals it handles. ... and syscall restarting happen at the user-system boundary; ... the kernel to back out of locks and other state changes that it had ... But POSIX ...
    (rec.arts.sf.written)
  • Re: Using SetConsoleCtrlHandler
    ... "The POSIX subsystem uses kernel-mode APCs to emulate the delivery of POSIX ... signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without the ... void handler { ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Using SetConsoleCtrlHandler
    ... Assuming the signal handler does the minimum (ie. set a global, ... Only a single-threaded POSIX ... POSIX signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without the ...
    (microsoft.public.win32.programmer.kernel)