[ECOS] Question about PThreads and signals

Bart Veer bartv@ecoscentric.com
Tue Sep 22 13:10:00 GMT 2009

>>>>> "Alexander" == Alexander Aganichev <aaganichev@gmail.com> writes:


    Alexander> And sigwait() not wakes on the signal from TCP/IP
    Alexander> stack. The root of the problem seems to be in the
    Alexander> cyg_sigqueue() code, which do the following:

    Alexander> ==
    Alexander>     if( thread != NULL )
    Alexander>     {
    Alexander>         sigaddset( &thread->sigpending, signo );
    Alexander>         // just wake the thread up now if it's blocked somewhere
    Alexander>         if ((thread->sigpending & ~thread->sigmask) != 0)
    Alexander>         {
    Alexander>             thread-> thread->set_asr_pending();
    Alexander>             thread-> thread->release();
    Alexander>         }
    Alexander>     }
    Alexander> ==

    Alexander> I think that thread->sigmask should not be used
    Alexander> non-inverted here, so that's why my thread is not waked
    Alexander> (have not tested the reverted condition though). Can
    Alexander> anyone please comment if I'm right? Thanks in advance.

I don't think so. thread->sigmask holds the signals which are
currently masked. Therefore (thread->sigpending & thread->sigmask)
holds the signals which are both pending and masked, but since those
signals are masked no action should be taken at this time.
(thread->sigpending & ~thread->sigmask) holds the signals which are
pending and not masked, i.e. which require attention at the earliest

I would suggest that, rather than trying to debug the problem in a
complicated application including the TCP/IP stack, you try to write
some simple test code which just has a couple of POSIX threads and
involves sending signals between them. There are some existing
signal-related testcases in compat/posix which may prove useful.


Bart Veer                                   eCos Configuration Architect
eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
 >>>> Visit us at ESC-Boston  http://www.embedded.com/esc/boston <<<<
 >>>> Sep 22-23 on Stand 226  at Hynes Convention Center, Boston <<<<

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list