This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wake select() with a signal


Roland Caßebohm wrote:
> 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.

Hmmm... Before the scheduler lock, the ASR should run. After the scheduler lock, nothing should be able to trigger an ASR to be scheduled; in particular nothing should be able to call pthread_kill. You're not calling pthread_kill from an ISR by any chance are you?

Oh, hold on, is it just that the pthread_kill is happening before the lock for the first time? If so, then I'm afraid that's tough - you could just as easily have pthread_kill'd it when the CPU was just making the call into the select function. From a programmatic point of view, that can just as easily happen. But your signal handler should definitely run regardless, or are you saying it doesn't do that either?

> Does anybody know if the select() systemcall or every other systemcall
> should always return if the thread receives a signal?

It should return if select() is actually waiting at the time.

Jifl
--
eCosCentric http://www.eCosCentric.com/ <info@eCosCentric.com>
--[ "You can complain because roses have thorns, or you ]--
--[ can rejoice because thorns have roses." -Lincoln ]-- Opinions==mine


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]