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

> I was just wondering if you can use floating point while servicing a
> syscall in the kernel? Doing a
> find -name \*.c -exec grep float {} \; -print
> turned up a couple drivers that seem to be using fp. Are there any
> known issues that I should to be aware off?
>
> Thanks,
> Mike
>

Tell the driver maintainer that you found a BUG. There is no floating-
point allowed in the kernel because the state of the FP Unit is
undefined in the kernel. If you 'define' it, i.e., `finit` then you
will mess up somebody who was using the FP Unit in user-mode.

Also, the '386 FP emulation, which is still supported, can produce a
double-fault if you try to use it (at some places) in kernel-mode
code.

Basically, there is nothing in the kernel that will ever require
floating point. Use fixed point if you need 'decimals' and stuff for
printing.

Note that many of the drivers, such as
../linux/drivers/net/hamradio/soundmodem, have programs which execute
during compile-time to generate tables of integer values. These programs,
which execute in user-mode during compile, can (and do) use any math that
they want including floating-point.

So a `grep` of the sources doesn't give you enough information. Also
there are some floating-point operations to be executed by the compiler,
the result being an integer constant such as:

long int radians = (long) (2.0 * 3.141592654 * (float) HZ);

You really need to look at the source to see if floating-point is
being used in the kernel. It should not be. Sometimes, there are
little bits that sneak through. This usually doesn't hurt anybody
because it occurs once during the startup code of a driver. Now
that drivers can be modules, that can be inserted at any time, it
is particularly important to make sure FP operations are not occurring
to print some simple sign-on string.

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:45    [W:0.061 / U:2.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site