Re: Threads signalling issue [was RE: threads change]

[email protected] (Nicholas Clark)
Newsgroups perl.perl5.porters,perl.ithreads
Message-ID <[email protected]>
On Fri, Jul 14, 2006 at 05:39:09PM -0700, Jan Dubois wrote:
> On Fri, 14 Jul 2006, Artur Bergman wrote:
> > It is threadsafe in the sense you won't crash, but PL_sig_pending
> > might be set to 0 by the running thread and thus not cause the
> > signal to be delivered until another signal is raised.
> 
> Not true, the dispatcher checks the signals *after* resetting the
> PL_sig_pending flag:

Does "after" hold on an SMP machine without any form of locking, where
processor A makes the changes in order, but processor B sees the later
change before the former? I thought that without mutexes there was no
reliable before or after for SMP systems where memory is written back in
any order.

> void
> Perl_despatch_signals(pTHX)
> {
>     dVAR;
>     int sig;
>     PL_sig_pending = 0;
>     for (sig = 1; sig < SIG_SIZE; sig++) {
>         if (PL_psig_pend[sig]) {
>             PERL_BLOCKSIG_ADD(set, sig);
>             PL_psig_pend[sig] = 0;
>             PERL_BLOCKSIG_BLOCK(set);
>             (*PL_sighandlerp)(sig);
>             PERL_BLOCKSIG_UNBLOCK(set);
>         }
>     }
> }

Nicholas Clark
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.