As Rivet developer and Rivet packager for Debian/Ubuntu I wouldn't give up the chance of having it installed onto any strain of Unix using the Tcl library provided by the OS, whether threaded or not. I even proposed a workaround for Harald's problem based on Tcl threads that achieved what asynchronous programming failed to achieve given the missing notifier (Harald rejected the solution on the basis of other constraints)

Needless to say, if TCT decided that Unix fork (with the fork1 semantics) is fundamentally incompatible with Tcl and hence assume to have complete freedom at creating ancillary threads that could be in any state by the time a fork is called we would take it into account.

 -- Massimo


On Thu, Jul 25, 2013 at 5:58 PM, Joe English <jenglish@flightlab.com> wrote:

Alexandre Ferrieux wrote:
>
> Clearly two writers and two readers on a single pipe, just call for disaster.
> So, to fix that, it looks like pthread_atfork should be used to create
> a fresh pipe and overwrite the proper global in one of the offspring.
> [...]
>
> Note that nothing special is needed for mutexes or condvars, because
> they dwelve in the per-process address space, hence get properly
> duplicated by fork(), unlike the pipe.

As I understand it, the situation is precicely the opposite:
mutexes and condition variables are the chief reason *why*
fork() and threads don't mix.

For example, suppose thread A calls fork() while thread B has
a mutex locked.  If (as is usually the case) mutexes are
implemented in whole or in part by shared memory spinlocks,
then the mutex will remain locked in the child process,
and since there is no copy of thread B running there,
it remains locked indefinitely.

pthread_atfork() doesn't really help here, for various reasons.

BTW, concerning the initial problem of Tcl's notifier thread
vs. Apache MPM: why not just build Tcl --disable-threads?
That ought to avoid most of the notifier issues.


--Joe English

  jenglish@flightlab.com

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Tcl-Core mailing list
Tcl-Core@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core