Stefano,
> thanks for your two interventions on the subject, they helped me
> understand that pthread_wakeup_np from an ISR is probably
> useful for my
> case.
It usually is.
> Without boring you with details, the structure of my ISR is:
>
> I_handler{
> /*Data acquisition*/
> /*Computations*/
> pthread_wakeup_np(my_thread);
> }
>
> While computations have to be done before the next interrupt,
> stuff done
> in my_thread has not this restriction (In other words it'a sort of
> background task).
Then, in fact, you have two threads. I do not know how much work
your "computations" amount to, but in general I would code this something
like this:
I_handler {
/* Data Acquisition */
pthread_wakeup_np(fast_thread);
}
fast_thread {
/* Computations */
pthread_wakeup_np(my_thread);
pthread_suspend_np();
}
This gets you out of the interrupt context as quickly as possible to
give other devices a chance at the bus. Of course, if you are so tight for
time that you *can not* tolerate *any* additional latency, then your way is
better. If that is your current situation, however, I would *strongly*
council you to get a faster processor.
Be sure, however, that fast_thread has a higher priority than
my_thread. Otherwise, in the cases where my_thread does not complete before
the next interrupt, it might execute before fast_thread.
> If I understand what you wrote it's not a problem if my_thread doesn't
> finish his work before the next interrupt. I_handler will
> execute anyway.
Absolutely. The pthread_wakeup_np will send the signal to the
thread (which will already be awake) and then call the scheduler, as normal.
> Is all this too contorted ? Does a simpler way exists ?
No, no it isn't. Yes, yes it does - as I have suggested.
Regards,
Steve
P.S. Again - If I am giving any bad advice here, I expect to hear from the
Gurus.
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/