[ECOS] Re: Question about PThreads and signals

Alexander Aganichev aaganichev@gmail.com
Mon Sep 21 09:32:00 GMT 2009


Tested with reverted condition. From my application point of view it
looks much better and seems to work properly. Though I'm not sure it
will not broke anything else.

On Fri, Sep 18, 2009 at 5:45 PM, Alexander Aganichev
<aaganichev@gmail.com> wrote:
> Hello,
>
> Just wondering if the problem I'm running in is known or I'm doing
> something wrong. I modified TCP/IP stack to send SIGIO signal to the
> POSIX thread with pthread_kill like this:
>
> ==
> #if 1 // SIGIO/FIOSETOWN
>        if (so->so_state & SS_ASYNC)
>                pthread_kill(so->so_pgid, SIGIO);
> #endif
> ==
>
> I also modified the code to properly set so_pgid field and double
> check that. From the user code I have the following:
>
> ==
>        sigaddset( &signals, SIGIO );
>        pthread_sigmask( SIG_BLOCK, &signals, &oldSignals );
>
>        while ( pGlobalParams->State == EventTask_Running )
>        {
>                sigwait( &signals, &sig );
> ==
>
> And sigwait() not wakes on the signal from TCP/IP stack. The root of
> the problem seems to be in the cyg_sigqueue() code, which do the
> following:
>
> ==
>    if( thread != NULL )
>    {
>        sigaddset( &thread->sigpending, signo );
>        // just wake the thread up now if it's blocked somewhere
>        if ((thread->sigpending & ~thread->sigmask) != 0)
>        {
>            thread->thread->set_asr_pending();
>            thread->thread->release();
>        }
>    }
> ==
>
> I think that thread->sigmask should not be used non-inverted here, so
> that's why my thread is not waked (have not tested the reverted
> condition though). Can anyone please comment if I'm right? Thanks in
> advance.
>
> --
> WBR, Alexander
>



-- 
WBR, Alexander

--
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