From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Boris V. Guzhov" To: "Jonathan Larmour" Cc: Subject: Re: [ECOS] select() and signal's Date: Sat, 21 Apr 2001 06:02:00 -0000 Message-id: <006401c0ca63$1bd96920$7601a8c0@borg> References: <01b701c0c996$c29891f0$7601a8c0@borg> <3AE0404E.B3BE865C@redhat.com> <01f801c0c9ab$be16cdd0$7601a8c0@borg> <3AE097E4.54468B43@redhat.com> X-SW-Source: 2001-04/msg00281.html I tried and it works. But there are some questions. Now pthread_kill() interrupts not only select(), but also sem_wait(). As far as I know, the POSIX semaphores are a general and exclusive synchronization mechanism with a signal-cathing function. And their functions should not be interrupted by signals. In Linux inplementation pthread_kill() not interrupts the sem_wait(). That's right? -- Boris Guzhov, St.Petersburg, Russia > "Boris V. Guzhov" wrote: > > > > But it still not works. > > Both threads have an equal priority. > > I carefully has looked on cyg_sigqueue() code. > > And I don't understand as cyg_sigqueue() function will wake > > the blocked in select() thread. > > The cyg_sigqueue() function calls only signal_sigwait.broadcast(). > > But the blocked thread sleeps on other condition variable - selwait, > > but not on signal_sigwait. > > Try the attached patch and let me know how you get on. I've only done some > simple tests. But I want you to try it with your existing code rather than > me spending more time on it[1]. *Do* let me know the outcome. > > Jifl > > [1] Since you're not a customer :) > -- > Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062 > Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine ---------------------------------------------------------------------------- ---- > ? foo > Index: signal.cxx > =================================================================== > RCS file: /home/cvs/ecc/ecc/compat/posix/current/src/signal.cxx,v > retrieving revision 1.11 > diff -u -5 -p -r1.11 signal.cxx > --- signal.cxx 2001/02/14 01:25:44 1.11 > +++ signal.cxx 2001/04/20 20:08:54 > @@ -61,12 +61,13 @@ > #include // our header > #include > #include // _exit > > #include > - > +#include > #include > +#include > > // ------------------------------------------------------------------------- > // Internal definitions > > // Handle entry to a signal package function. > @@ -239,16 +240,33 @@ cyg_bool cyg_sigqueue( const struct sige > ss->pending = si; > } > // else A non-queuable signal, just set it pending > > if( thread != NULL ) > + { > sigaddset( &thread->sigpending, signo ); > - else sigaddset( &sig_pending, 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(); > + } > + } > + else > + { > + sigaddset( &sig_pending, signo ); > + // Wake up any threads in sigsuspend() and sigwait(). > + if (!signal_sigwait.get_queue()->empty()) > + { > + signal_sigwait.broadcast(); > + } > + else > + { > + cyg_posix_pthread_release_thread( &sig_pending ); > + } > + } > > - // Wake up any threads in sigsuspend() and sigwait(). > - signal_sigwait.broadcast(); > - > if( !locked ) signal_mutex.unlock(); > > return true; > } > >