On Sun, 2002-04-21 at 08:33, Oleg Goldshmidt wrote:
> Gilad Ben-Yossef <[EMAIL PROTECTED]> writes:
> 
> > Thus spake Rusty (of ipchains/tables fame):
> > http://kernelnewbies.org/documents/kdoc/kernel-hacking/basic-rules.html
> 
> Yes, I am aware of that. However, if you do not regard implementation
> of (e.g.) exp an issue separate from the general FPU safety of the
> kernel, it seems to me that the only solution is to implement your
> own exp. I am quite loath to that.

AFAIK it might be an issue whenever the FPU is used in kernel context
without due care. I agree there writing your own exp is by far not the
right solution.

> Incidentally, I could not find anything that would give an example of
> the proper solution to the problem if one absolutely must use floats.

The solution is obvious once you note that proccesses share the FPU
between each other already. The kernel keeps tab if a proccess uses the
FPU or not (I believe it is current->used_math) when it runs and if it
does the kernel will save the FPU state when that proccess is switched
off the CPU and restores it  when the proccess is switch back onto the
CPU. 

You simply have to do the same thing. For i386 (or really the i387 ;-)
the implmentation is in /arch/i386/kernel/i387.c and I suspect only mild
tweaking, if any, is required to adapt it for your needs. The only
difference is that it seems (I'm not really sure why, btw) that the
state is saved into process owned memory, you might want to save it to a
kernel memory buffer instead for better performance.

You owe the Internet Oracle an implmentation of a kernel module to
implement /dev/pi using the i387 FPU ;-)

-- 
Gilad Ben-Yossef <[EMAIL PROTECTED]>
Code mangler, senior coffee drinker and VP SIGSEGV
Qlusters ltd.

"To err is human. To realy fsck up you need a computer. For
 those really large scale disastears, an SSI cluster is a must."





=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to