On Fri, 14 Jul 2006, Jerry D. Hedden wrote:
> If you mean that PL_psig_pend[signal], etc. should be
> locked:
>
> /* Set the signal for the thread */
> thread = SV_to_ithread(aTHX_ ST(0));
> MUTEX_LOCK(&thread->mutex);
> if (thread->interp) {
> dTHXa(thread->interp);
>
> /*** SET A "SIGNAL" LOCK HERE ***/
> PL_psig_pend[signal]++;
> PL_sig_pending = 1;
> /*** UNLOCK HERE ***/
>
> }
> MUTEX_UNLOCK(&thread->mutex);
>
> then what should the fix be? Anyone?
I explained before that this code is threadsafe because the actual value
of PL_psig_pend[signal] is irrelevant as long as it is set to a non-zero
value, which is what you'll do even if the increment is non-atomic.
There is also no problem if the receiving thread processes the signal
before PL_sig_pending has been set. All that is going to happen that it
will waste a few cycle checking for pending signals again and not
finding any.
There is no need to add any locking to the code above as long as Perl
isn't implementing "queued" signals.
Cheers,
-Jan
PS: I'm not seeing any of Artur's messages; aren't they being copied to
p5p?