Francois Desruisseaux wrote:
>
> I have a general question about using LXRT with pthreads, and I have a
> specific problem about which I'd be grateful to get some ideas.
>
> First, the general question: I have an LXRT process in which I start
> multiple threads (using the standard Linux pthread implementation, where
> the include file credits Xavier Leroy), and I want to make RTAI calls in
> more than 1 thread. Should each thread that will call the RTAI API, call
> rt_task_init to have its own RTAI proxy, or is a single call in the main
> thread enough ?
You need a proxy for each thread, look at the examples. In Linux threads
are just processes that shares memory space.
> And the problem: The reason I ask is I have a problem where rt_sem_wait
> does not wait for a non-signaled semaphore. I confirmed (by tracing
> rt_sem_... calls in the upscheduler/rtai_sched.c module) that the
> semaphore is created with a value of 0 and is never signaled. When
> entering rt_sem_wait, sem->count becomes < 0 and rt_schedule is called,
> and the same process keeps on running. Since this call was made in a
> thread which had not called rt_task_init, I thought that the calling
> LXRT task does not have a proxy and does not exist as far as the RT
> scheduler is concerned, and so cannot be suspended. So I tried adding a
> call to rt_task_init at the beginning of the thread, but the symptoms
> did not change.
Clearly you cannot use any RTAI call if you do not create a proxy. So
the first part is as expected. Once you init the proxy it should work.
> In simple examples/tests, rt_sem_wait works fine. The problem occurs in
> a large body of code (being ported from QNX). I'll try to duplicate it
> in stand-alone example code. Meanwhile, does anyone have a hint or a
> solution ?
I'll wait for you duplication of the problem to work on any fix. At the
moment I find it difficult to say more. BTW use pthread just to create
them an no other Linux pthread service.
Ciao, Paolo.
-- [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/