This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Wake select() with a signal
- From: Roland Caßebohm <roland dot cassebohm at visionsystems dot de>
- To: ecos-discuss at sources dot redhat dot com
- Date: Mon, 4 Nov 2002 18:53:50 +0100
- Subject: Re: [ECOS] Wake select() with a signal
- References: <200211011804.31718.roland.cassebohm@visionsystems.de>
On Friday, 1. November 2002 18:04, Roland Caßebohm wrote:
> Hi everyone,
>
> I want to wake a waiting select by sending a signal to the thread.
>
> This does not always work. I think the reason is that the thread in which
> select() is call is not really sleeping all the time, even though it
> doesn't return. The pthread_kill() function respectively
> Cyg_Thread::release() only wakes a thread if the thread is sleeping. That
> makes sense, but what can I do if I want a waiting select() to return
> triggered from another thread?
>
I just changed the select() function that it looks for the asr_pending flag before it goes to sleep. I don't really think, that this is the right solution, but in my case it works.
Now the select() always returns with errno=EINTR if the thread receives a signal.
Does anybody know if the select() systemcall or every other systemcall should always return if the thread receives a signal?
Roland
Index: io/fileio/current/src/select.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/fileio/current/src/select.cxx,v
retrieving revision 1.8
diff -u -5 -p -r1.8 select.cxx
--- io/fileio/current/src/select.cxx 9 Aug 2002 17:10:21 -0000 1.8
+++ io/fileio/current/src/select.cxx 4 Nov 2002 17:35:02 -0000
@@ -209,10 +213,22 @@ select(int nfd, fd_set *in, fd_set *out,
select_mutex.unlock();
FILEIO_RETURN_VALUE(num);
}
Cyg_Scheduler::lock();
+
+#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT
+ Cyg_Thread *self_thread = Cyg_Thread::self();
+ if (self_thread->get_asr_pending())
+ {
+ error = EINTR;
+ Cyg_Scheduler::unlock();
+ break;
+ }
+#endif
if( wake_count == selwake_count )
{
// Nothing found, see if we want to wait
if (tv)
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss