lkml.org 
[lkml]   [2000]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Question: Using floating point in the kernel
On Wed, 20 Sep 2000, Timur Tabi wrote:

> ** Reply to message from "Lyle Coder" <x_coder@hotmail.com> on Wed, 20 Sep 2000
> 01:50:05 GMT
>
>
> > You cannot use MMX registers in the kernel either, since the kernel doesen't
> > save and restore FX state (fxsave, fxrstor) either (just like
> > (fsave/frstor).
>
> But what about these source files:
>
> include/asm-i386/mmx.h (which several other header files, like asm-i386/page.h,
> include)
> arch/i386/lib/mmx.c
> arch/i386/lib/usercopy.c
>
> It appears that MMX is being used in the kernel already.
>
>

Well the code does a fnsave. Somebody never looked at the damn book! it
takes 143 clocks for this, plus at least 3 for fwait. Then it sets a
flag to let return code 'know' if the context has to be restored. This
code `exists` sort of like moss. I don't think it is ever executed and
if it is, you get to keep both broken pieces.

If you are going to use floating-point, you __must__ save and restore
the state of the FP unit for every context-switch. With multiple CPUs,
you have to save/restore the state of the right CPU. etc.

And for what?
So someone can do something stupid and put floating-point in the kernel.
Floating-point is used for mathematics on fractional real numbers.
There aren't any in the kernel. If you need fractional parts, which
is most unlikely in a binary operated device, then you must express
them as the ratio of two integers. Which, I will point out, is often a
much more accurate way of handling numbers. 1/3 is denoted exactly.
0.333333...... will never be.


Cheers,
Dick Johnson

Penguin : Linux version 2.2.15 on an i686 machine (797.90 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.082 / U:5.876 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site