<div dir="ltr">Thanks @Peter a very good explanation and it's very help full to me.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 29 July 2014 19:49, Peter Teoh <span dir="ltr"><<a href="mailto:htmldeveloper@gmail.com" target="_blank">htmldeveloper@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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):<div>
<br></div><div><a href="http://en.wikipedia.org/wiki/SSE2" target="_blank">http://en.wikipedia.org/wiki/SSE2</a></div><div><a href="http://www.godevtool.com/TestbugHelp/XMMintins.htm" target="_blank">http://www.godevtool.com/TestbugHelp/XMMintins.htm</a> <br>
</div><div><a href="http://x86.renejeschke.de/html/file_module_x86_id_117.html" target="_blank">http://x86.renejeschke.de/html/file_module_x86_id_117.html</a><br></div><div><br></div><div>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.</div>
<div><br></div><div>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. </div>
<div><br></div><div>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.</div>
<div><br></div><div>Thanks for the reading.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="">On Wed, Jul 23, 2014 at 11:15 AM, me storage <span dir="ltr"><<a href="mailto:me.storage126@gmail.com" target="_blank">me.storage126@gmail.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class=""><div>Hi<br></div><div>I am reading LDD .In that i didn't understand one point .In Chapter 2(Building and Running Modules) they mentioned that<br>
" Kernel code cannot do floating point arithmetic"<br>
</div><div>.My doubt is which code is used for floating point arithmetic that means at low level?<br><br></div></div><div>Thank you<br></div></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Regards,<br>Peter Teoh
</font></span></div>
</blockquote></div><br></div>