Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Mar 2007 11:44:46 -0700
From:      "Coleman Kane" <zombyfork@gmail.com>
To:        freebsd-hackers@freebsd.org, maslanbsd@gmail.com
Subject:   Re: Floating-point in kernel space
Message-ID:  <346a80220703091044p5759e6do521065203299c26b@mail.gmail.com>
In-Reply-To: <200703091021.l29ALLVw067285@lurza.secnetix.de>
References:  <319cceca0703090116p7e768630qd055be57bbe4953@mail.gmail.com> <200703091021.l29ALLVw067285@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On 3/9/07, Oliver Fromme <olli@lurza.secnetix.de> wrote:
>
> Maslan <maslanbsd@gmail.com> wrote:
> > I think i've seen somewhere but i don't remember that floating point
> > arithmetic is not allowed in kernel space, if that's right, can anyone
> > please tell why ???
>
> Because the overhead of swapping the contents of the FPU
> registers on every context switch within the kernel.
> So far there has been no compelling reason for having FP
> support in kernel code that would justify to pay that
> price.
>
> > and why not not emulate the floating point in kernel space ???
>
> First, FPU emulation is rather slow, and second, someone
> would have to write the code.  In the past, the FreeBSD
> kernel had two FPU emulation libraries (for emulation
> of FPU instructions in userland).  One was BSD-licensed,
> but incomplete and not 100% compatible, and the second
> was GPL, so it couldn't be enabled by default.  As far as
> I know, both of them were removed because hardware without
> an FPU was considered obsolete, and nobody was willing to
> improve and maintain the code.
>
> Let me ask you, why would you want to have floating point
> support in the kernel?  Most of such typical uses can
> easily be replaced by simple fixed-point arithmetic with
> integer instructions.  There are several examples of such
> code, e.g. in ALTQ, DUMMYNET and in the NTP support code.
>
> Best regards
>    Oliver
>
> --
> Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
> Handelsregister: Registergericht Muenchen, HRA 74606,  Gesch=E4ftsfuehrun=
g:
> secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht M=FC=
n-
> chen, HRB 125758,  Gesch=E4ftsf=FChrer: Maik Bachmann, Olaf Erb, Ralf Geb=
hart
>
> FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd
>
> "I have stopped reading Stephen King novels.
> Now I just read C code instead."
>         -- Richard A. O'Keefe


It would be helpful to know why you need this support as well. For many
projects that I've done, the kernel code is used for transferring the
"binary" data from the computer system (hardware or kernel) to a userland
daemon that would do the FP processing (which is likely significantly time
consuming) and then this daemon would provide a listening socket that other
software could use to retrieve said data.

I would imagine that if you are needing FP processing in the kernel, then
you'll be doing a serious amount of work and may not want to be hogging up =
a
lot of kernel time doing it. However, there are Real-Time applications for
such an implementation. Perhaps posting about the problem would be more
helpful.

--
Coleman Kane



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?346a80220703091044p5759e6do521065203299c26b>