This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Question about PThreads and signals
- From: Bart Veer <bartv at ecoscentric dot com>
- To: Alexander Aganichev <aaganichev at gmail dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Tue, 22 Sep 2009 14:09:50 +0100
- Subject: Re: [ECOS] Question about PThreads and signals
- References: <c25335bc0909180645g3418fcb3qfd1a9020a6d2333a@mail.gmail.com>
>>>>> "Alexander" == Alexander Aganichev <aaganichev@gmail.com> writes:
<snip>
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
opportunity.
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
--
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