invalid use of FPU in Xenomai context
I made some more progress in porting my RTLinux application, but now I'm spinning my wheels trying to track down the source of the following error:
"invalid use of FPU in Xenomai context at ..."
I am doing floating point calculations inside a real-time POSIX thread in kernel-space. I am puzzled because I can create a simple test program that uses floating point operations in a real-time thread without any errors. I create the task with something like this:
pthread_attr_init(&attr);
pthread_attr_setfp_np(&attr, 1);
result = pthread_create(&fptest_task, &attr, &fptest_routine, NULL);In fact, it seems that the fp attribute is already 1 by default, because I get no floating point errors if I leave out the pthread_attr_setfp_np line. I do get an error if I do this:
pthread_attr_setfp_np(&attr, 0);
I am doing the same thing in my much more complicated real-time application. In fact, I can even insert a loop with some floating-point code at the beginning of my thread, and it works fine. The problem is that something in my application code is triggering the "invalid use of FPU" error.
Does anyone have any ideas of what could trigger this besides not setting the fp attribute for the thread?
Thanks,
Jeff
Quoted 3 lines · Jeff Webb
I made some more progress in porting my RTLinux application, but now I'm spinning my wheels trying to track down the source of the following error:
"invalid use of FPU in Xenomai context at ..."
This message also gives the faulty location/symbol+offset. Where does it point to?
Signature · 1 line
Philippe.
Quoted 1 line · Jeff Webb
Does anyone have any ideas of what could trigger this besides not setting the fp attribute for the thread?
What version of Xenomai do you use ? I have updated the FPU support very recently, so it would be interesting to know if you also get the error when applying or reverting this change.
Signature · 1 line
Gilles Chanteperdrix.
Quoted 7 lines · Philippe Gerum
Quoted 3 lines · Jeff Webb
I made some more progress in porting my RTLinux application, but now I'm spinning my wheels trying to track down the source of the following error:
"invalid use of FPU in Xenomai context at ..."
This message also gives the faulty location/symbol+offset. Where does it point to?
It's coming from some simple floating point operations in my application code. The relevant code snippet is:
print_msg(TRACE_MSG, "rt_delay_sim\n"); print_msg(INFO_MSG, "jeff rt_delay: 1\n"); actual_dt = sim_dt / rt_speed_factor + rt_skew_correction; print_msg(INFO_MSG, "jeff rt_delay: 2\n");
The kernel message output is:
Sep 15 09:17:34 kernel: rt_delay_sim
Sep 15 09:17:34 kernel: jeff rt_delay: 1
Sep 15 09:17:34 kernel: invalid use of FPU in Xenomai context at [fc264152]
Sep 15 09:17:34 kernel: Xenomai: suspending kernel thread c1ca3730 ('c1ca3730') at
0xfc264152 after exception #7The variables in question are doubles. The faulty location offset is somewhere in the rt_delay_sim routine, as you would expect from the output above. This specific code does not appear to be the problem, though. If I remove the call to the rt_delay_sim routine, I simply get a floating point exception in another location.
The strange thing is that I can do a loop of floating point operations at the beginning of my real-time thread without any problem:
for (i=0; i<1001; i++)
{
f = f * 1.0 + 0.1; };
print_msg(INFO_MSG, "f = %d\n", (int)f);
but once I get into my real application code, I get the above error after executing several floating point operations. My 'real application code' is actually a linked list of routines that reside in other kernel modules. I wish I could come up with a simple example that caused the same problem... I will keep trying.
As I said before, I am porting an application that works properly under RTLinux GPL, and am making some small changes to compile with Xenomai POSIX threads/timers and RTAI FIFOs.
Thanks,
Jeff
Quoted 6 lines · Gilles Chanteperdrix
Quoted 1 line · Jeff Webb
Does anyone have any ideas of what could trigger this besides not setting the fp attribute for the thread?
What version of Xenomai do you use ? I have updated the FPU support very recently, so it would be interesting to know if you also get the error when applying or reverting this change.
I am using Xenomai-2.2.2 with the two RTAI FIFO patches posted by Philippe a few days ago. Do you have a patch that undoes the changes? I could probably figure out how to generate one from subversion, if you know the revision of the change. I do need the recent FIFO patches for the rest of my application to work properly, or I would just try an old version.
I am using the 2.4 x86 UP kernel, if that makes any difference.
Thanks,
-Jeff
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jeff Webb
Quoted 6 lines · Gilles Chanteperdrix
Quoted 1 line · Jeff Webb
Does anyone have any ideas of what could trigger this besides not setting the fp attribute for the thread?
What version of Xenomai do you use ? I have updated the FPU support very recently, so it would be interesting to know if you also get the error when applying or reverting this change.
Quoted 5 lines
Quoted 3 lines
I am using Xenomai-2.2.2 with the two RTAI FIFO patches posted by Philippe a few days ago. Do you have a patch that undoes the changes? I could probably figure out how to generate one from subversion, if you know the revision of the change. I do need the recent FIFO patches for the rest of my application to work properly, or I would just try an old version.
I am using the 2.4 x86 UP kernel, if that makes any difference.
Sorry, sent the wrong patch. Try this one.
Unfortunately, I get the same results with this patch applied. I haven't been able to isolate the problem yet. I did discover that putting in a clock_nanosleep call at certain points in my simulation loop allowed the loop to execute to completion without any FPU errors. Maybe this is a clue... I do still get an FPU error message at some point after the main simulation loop is done, though.
Any more ideas regarding the source of my problem? In my main loop, I am doing a few floating point calculations, stuffing some data to an RTAI FIFO, and then calling clock_nanosleep to wait for the next cycle.
Thanks,
Jeff