[Home]LXRT FAQs

Last edit: Peter Favrholdt on December 10, 2006 23:08 (3996 days, 15 hours and 51 minutes ago) (diff)
Rtai.Dk | RecentChanges | Preferences | DIAPM RTAI

Q: Compiling my LXRT program I get hundreds of errors in include file "rtai_lxrt.h".

A: To avoid this error messages you have to include "sys/types.h":

            #include        <sys/types.h>
            #include        <rtai_lxrt_user.h>


Q: It is not possible to establish a LXRT resource with a specific name.

A: Perhaps there is (another) resource with the same name (has not to be the same kind of object). A list of all registered objects you can find at "/proc/rtai/lxrt".


Q: Creating a Posix Thread the system crashs! Why?

A: Please check the following item: Are the datas for the initialization stored in a local variable? If yes: Will the Thread come to run and to start his buddy before the function is left? At this time the datas are still needed and if they are undefined in the meantime the thread may crash.


Q: My program starts, the threads will be created, but the program ends suddenly.

A: Independent of the state of the child threads the program is finished after reaching the end of main(). So you have to synchronize main() to the end of the threads (by a semaphore, an event called bit, or pthread_join()).


Q: After the call rt_task_delete() the thread still runs. Why?

A: rt_task_delete() only deletes the Buddy of the LXRT thread. The thread itself is still processed until the end of the thread is reached or pthread_exit() is called.

WARNING: If there is a call to the LXRT API after deleting the buddy of the called task there may be a crash of the system!


Q: The data flow of my program does not seem to be as expected. What to do?

A:


Q: In the kernel log is an entry like this: "BAD: null rt_fun_ext[x]". What's going wrong?

A: The application has made a lxrt service request, but the needed RTAI module or an expansion module has not been loaded before.


Q: Several Tasks are waiting for the same event pattern on the same event box (see "bits"). What will happen, if the pattern is sended?

A:


Q: is it necessary, that a process is scheduled by Linux as softrealtime process (SCHED_FIFO) before I call rt_task_init() and rt_make_hard_real_time() to run it as a hardrealtime LXRT process?

A: NO, but it should be better as you get a quicker Linux response during the soft preamble, usually there is one, and allows more extensive preliminary testing in soft mode.


Q: How can I control the automatically switching between hard and soft realtime?

A: Building the kernel there is a macro:

#define ALLOW_SYSW 1
If not defined the Linux syscall is simply forgotten and an immediate return is performed. If defined an automatically switch to soft realtime is performed.

With the macro

#define ECHO_SYSW 1
you can define that you will get an echo from the switch point. So you can check if there were any unexpected changes to soft realtime.


Q: Do I always need to call rt_task_init before calling RTAI functions from a normal linux task?

A: Most non scheduling functions can be called without having extended the Linux task structure to use RTAI APIs, that's what rt_task_init does.

Such a a way of doing the all stuff must be done with full knowledge, i.e. check if the related entry in the lxrt sys calls table is of type 0, otherwise it is better to first call rt_task_init anyhow before using RTAI in user space.

E.g. rt_get_name is always non blocking but rt_sem_wait is not.


Q: How to delay scheduling until the ISR (interrupt service routine) has finished?

A: You have to do:


Q: How do I destroy a blocked LXRT task?

A: As long as you have not gone hard realtime, you can either install a control-C handler in your application (i.e signal(SIGINT, cntrlChandler) ) or you can do a "killall yourApp". Once you go hard realtime, neither your ^C handler nor killall will work. You will have to build some mechanism in your code to come out of hard realtime and shut down gracefully.


Q: How do I implement the LXRT-API for my kernel module (like rtnet, ...)?

A: Answer still needs to be written...

from the mailinglist:
> do you have any instructions, how the rtnet-kernel-functions
> are called from userspace? Exspecially what these UR1, UW1,
> UR2... macros are good for!?

There is a pretty good explanation in rtai_lxrt.h on these. Basically,
these macros help encode the structure of the parameters being passed.
The UR[12] And UW[12] are for "userspace read" and "userspace write."
These allow two blocks of memory to be read from userspace and two
blocks of memory to be written to userspace automagically by the LXRT
framework.

[SNIP]
> I tried to call rtai_lxrt() as it is called in the other functions,
> but I think it does not work (always returns -107).
[SNIP]

The problem with rt_socket_recvfrom is that there are 3 parameters that
are "write to" userspace, but the LXRT framework only supports 2 write
blocks. AFAIK, rt_socket_recvfrom is not implemented (correctly, if at
all) for LXRT. If it was to be implemented (correctly), it would have to
take special consideration for copy to/from userspace for this third
parameter (likely to be the fromlen argument, since it needs to be read
and written). Alternatively, you could try and update the LXRT framework
to allow for 3 userspace read/write blocks (but I think there is a
shortage of bits in the encoding).


Q: How can I determine system load caused by RTAI/lxrt tasks (something like /proc/loadavg for RTAI/lxrt-tasks)?

A: /proc/rtai/scheduler gives exec time information on a per-task basis.


Q: I noticed that linux's /proc/loadavg shows unusual linux load when a RTAI scheduler runs(even when RTAI tasks are almost idle)?

A: This comes from the fact that some internal daemons started by LXRT (kthread_b, kthread_m) are waiting for requests in TASK_UNINTERRUPTIBLE state, so their cumulated wait time is charged as being actual load by Linux.


Q: Is it possible to use the ioctl interface from a lxrt or newlxt based application if this application works in hard real-time mode ?

A1: No, since that would call linux kernel functions (inclusive the linux scheduler) while running in hard realtime.

A2: Usually the ioctl() ends up in some device driver function calls. If you have the source implementing the driver you can find out which functions are called by the driver's ioctl() handler. Knowing these calls, you can start either call them directly (kernel mode) or you build a LXRT wrapper for these calls (user mode).


Q: Is there a call like rt_get_cpu_time_ns that will give nano-second accuracy in user space?

A: Yep, rt_get_[cpu]_time_ns() is available in user space. See rtai/include/rtai_lxrt_user.h for available functions


Edit text of this page | View other revisions | Download Rtai.dk
Search: