[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
[rtl] a bug in fpu-state saving/restoring?
Hello to all the people in rtlinux mail list,
by the moment only a quick question (now I'm very busy. I expect to give
more details the next week).
Why does this realtime task work all right?:
************************************************************************
unsigned char fpstat[108];
void functtr(int t)
{
while(1) {
/* Sorry about this if it is not completely right. This is the
first time I use the "asm" directive. But it works. */
__asm__(" fsave %0" /* Save FPU state. */
:"=m" (*fpstat)
:
:"memory");
/* A lot of mathematical operations (floating point) and
functions of libm.a here ...*/
/* ... and then data are sent to a Linux task. */
__asm__(" frstor %0" /* Restore FPU state. */
:
:"m" (*fpstat)
);
rt_task_wait();
}
}
*********************************************************************
and doesn't this one if it's the way must be done?:
********************************************************************
void functtr(int n)
{
rt_use_fp(1); /* This is its place in the examples of RT-Linux */
while(1) {
/* rt_use_fp(1); I tried also to put it here */
/* A lot of mathematical operations (floating point) and functions
of libm.a here .... */
/* ... and then data are sent to a Linux task. */
rt_task_wait();
}
}
************************************************************************
The first one works OK, but the second one makes the Linux task (not real
time) to obtain sometimes wrong results **only** in floating point
operations. Even the "top" command displays wrong data like this while
the second real time task is running:
CPU states: -35791394.-8% user, etc...
or something similar.
However with the first real time task running, my Linux task and the "top"
command both display correct values.
I'm using rtlinux-0.6-2.0.33 on a Pentium 120 with Debian Linux 1.3.1.
(and also on a Pentium 200).
Does the real-time scheduler have a bug or maybe am I doing something
wrong?. The great problem with real-time tasks is that system's code and
data are not protected (although this case could be an error in my task's
code and data which can't be found by me).
I expect somebody to have some idea with only this information. Soon I'll
give more details about the application I'm developing.
Thanks a lot.
Alberto.
Abel Alberto Cuadrado Vega.
Area de Ingenieria de Sistemas y Automatica.
Universidad de Oviedo.
Spain.
--- [rtl] ---
For more information on Real-Time Linux see:
http://www.rtlinux.org/