"David J. Christini" wrote:
>
> I've seen a couple of posts on this list regarding strange floating point
> related crashes. I'm having such a problem, and I can't seem to solve it.
>
> I believe it involves the fact that my floating point variables are in
> shared memory (using mbuff with volatile ... however I had the same
> crashing problems last week before I switched over to mbuff from the old
> shared memory approach). I #include <float.h> and pthread_setfp_np. I use
> the following shared memory struct:
>
> typedef struct {
> unsigned char head;
> int scan_index; //index holding current analog input scan
> int current_fp; //current value of fp
> int current_xx; //current value of state variable
> //float g; //g feedback proportionality control parameter
> int g; //g feedback proportionality control parameter
> unsigned int ai_chan[NUM_AD_CHANNELS_TO_USE];
> unsigned char tail;
> } SharedMemStruct;
>
> When I compile and run my application with only int's (as it currently
> reads), it doesn't crash. However if I change g to float, my application
> crashes my computer occasionally, but not always. The application has
> three floating point operations involving g.
>
> Is there anything I should be doing to avoid this? My application, which
> is a feedback control process, needs to use float for g, so I don't really
> know how to get around this ... the one thing I'm considering is trying
> RTAI ... any thoughts?
Hi Dave,
I have used RTLinux 0.9 (I suspect 2.0 works the same way) and RTAI-1.x
extensively with floating point operations and had no problems. The
only gotcha's are (I appologise if this is old news):
1/ You need to tell linux that it should save the FPU state on context
switch as it does not save these unless there is a process using the
FPU, on RTAI you need to say: rt_linux_use_fpu(1)
2/ You need to tell RT that your task is going to use the FPU, on RTAI
you set the use_fpu arg in the rt_task_init, on RTLinux V2 (as you have
said) you need to use pthread_setfp_np(task, 1);
Regards, Stuart
-- [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/