kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: htmldeveloper@gmail.com (Peter Teoh)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Doubt Regarding Floating Point Arithmetic
Date: Tue, 29 Jul 2014 22:19:57 +0800	[thread overview]
Message-ID: <CAHnt0GX3bVHzE-CP5rczwG7yokmTEotBSeKJs2BEQsFxUMe6hQ@mail.gmail.com> (raw)
In-Reply-To: <CAHmg6GNWLzKA-UMXFx5mJT6D+o23=pYTtNFPOdmDvdnT5XxC7w@mail.gmail.com>

Perhaps a little explanation:    anything that can be done at userspace,
should not be done at the kernel, simply because doing at the kernel
entailed a lot of security privileges being available.   (ie, logic which
require hardware interaction / access, process scheduling logic or anything
cutting across processes, sharing of common resources like memory etc)
floating point arithmetics is a good example which is not necessary to be
done in the kernel.   Lots of hardware registers are available for FPU
stuff (SSE/SSE2/XMM registers etc):

http://en.wikipedia.org/wiki/SSE2
http://www.godevtool.com/TestbugHelp/XMMintins.htm
http://x86.renejeschke.de/html/file_module_x86_id_117.html

and generally their usage entailed a lot of performance hits when used
extensively (another good reason to avoid it).   And more importantly,
context switching as  provided by Intel processor, the hardware operation
does not include the floating pointers registers (simply because there are
so many of them, and XMM can be like 128 bytes long?)   Context switching
will swap out the entire registers set when switching from one process to
another, and if u were to do this for all the process, when 99% of the time
floating point are not in use, it is a terrible waste of CPU cycle.

Userspace can only interact with the kernel through well-defined syscall -
for purpose of security, interprocess, or hardware access etc.   So
generally it is not possible to schedule floating point instruction (or any
user-defined instructions for that matter) to be executed in the kernel.

But it is possible to schedule floating point arithmetics to be executed in
the kernel indirectly, for example, when u have a special hardware like DSP
that does floating point arithmetics, and u wrote a driver to schedule
instructions to be executed in that hardware unit.  And u have to worry
about many processes concurrently sending instructions to the same unit as
well.

Thanks for the reading.



On Wed, Jul 23, 2014 at 11:15 AM, me storage <me.storage126@gmail.com>
wrote:

> Hi
> I am reading LDD .In that i didn't understand one point .In Chapter
> 2(Building and Running Modules) they mentioned that
>  " Kernel code cannot do floating point arithmetic"
> .My doubt is which code is used for floating point arithmetic that means
> at low level?
>
> Thank you
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>


-- 
Regards,
Peter Teoh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140729/b3d5945b/attachment.html 

  parent reply	other threads:[~2014-07-29 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23  3:15 Doubt Regarding Floating Point Arithmetic me storage
2014-07-23  4:35 ` Greg KH
2014-07-29 14:19 ` Peter Teoh [this message]
2014-07-29 16:31   ` Prasad Ram
2014-07-29 23:31     ` Peter Teoh
  -- strict thread matches above, loose matches on Subject: below --
2014-07-24  2:39 me storage
2014-07-24  4:18 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHnt0GX3bVHzE-CP5rczwG7yokmTEotBSeKJs2BEQsFxUMe6hQ@mail.gmail.com \
    --to=htmldeveloper@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).