Yukihiro Matsumoto
10/6/2008 11:15:00 PM
Hi,
In message "Re: Ruby lacks atfork : The evil that lives in fork..."
on Mon, 6 Oct 2008 13:32:30 +0900, John Carter <john.carter@tait.co.nz> writes:
|state(m) is merely reporting the value of $state and the whether the
|mutex was locked or not.
|
|For the time $state is "Inconsistent", the mutex should be in a locked
|state. Which it is, when view by any other thread _in the same
|process_.
|
|However, if you fork a process, the mutex in the child process is in
|the unlocked state whilst the resource is still in the inconsistent
|state.
When you fork off the process, the entire resources are (virtually)
copied, so that there's no way to ensure (copied) mutex to share
locking status across processes. The basic rule is: don't mix threads
(and thread related resources like mutex) with processes.
matz.