Can I use float or double in kernel mode?

Can I use float or double in kernel mode?

Regards
Mattias Bergkvist

You can but there is a bunch of overhead involved, see
KeSaveFloatingPointState for information. Why would you want floating point
in a file system? If not on a file system this is the wrong list to be
asking on go to NTDEV.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntfsd…
> Can I use float or double in kernel mode?
>
> Regards
> Mattias Bergkvist
>

I have an algorithm that calculates a value on the entire file.

First I try to open the file in user mode but after some questions on this forum I thought it was best to open the file in kernel mode instead.

Why would you want floating point in a file system?
So answer on your question is, it is because my algorithm that calculate the value on the entire file.

Regards
Mattias Bergkvist

> Why would you want floating point in a file system?

An accurate reponse, but deeply, deeply off topic:

In Vax/VMS there was a wonder hack in mount processing whereby you could
find the “topmost bit set” by converting a bitmask (expressed as an
integer), into a floating point of the correct type, stripping the exponent
out and using that as the index of the top most bit. This is useful when
you are wanting to find allocated/unallocated regions in the allocation map.

The details are hazy at this distance, but I know they used this knowledge
in the field to diagnose fault FP units (a failure with a crash after
SYSINIT started would mean “swap the FP board”).

It didn’t work too good when we ported to Alpha (which didn’t like FP in
kernel mode).

My apologies slight divergence from things NT, it’s been a long day…

/r

Rod,

No question floating point has its uses, I used it in Data General OS’es
years ago. But the bottom line is that there is a high cost in Windows to
save the state so you can use it, and to be honest many algorithms can be
recoded to use 64-bit ints which will be much faster.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Rod Widdowson” wrote in message
news:xxxxx@ntfsd…
>> Why would you want floating point in a file system?
>
> An accurate reponse, but deeply, deeply off topic:
>
> In Vax/VMS there was a wonder hack in mount processing whereby you could
> find the “topmost bit set” by converting a bitmask (expressed as an
> integer), into a floating point of the correct type, stripping the
> exponent out and using that as the index of the top most bit. This is
> useful when you are wanting to find allocated/unallocated regions in the
> allocation map.
>
> The details are hazy at this distance, but I know they used this knowledge
> in the field to diagnose fault FP units (a failure with a crash after
> SYSINIT started would mean “swap the FP board”).
>
> It didn’t work too good when we ported to Alpha (which didn’t like FP in
> kernel mode).
>
> My apologies slight divergence from things NT, it’s been a long day…
>
> /r
>
>

You can, but you must surround your FP work with
KeSave/RestoreFloatingPointState, otherwise, you will damage the FPU context of
some user app.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntfsd…
> Can I use float or double in kernel mode?
>
> Regards
> Mattias Bergkvist
>

I don’t know exactly what form of FP you are intending to use - x86,
MMU, et. c., and if you are planning on using intrinsics, but be aware
that CL has alignment issues/requirements with some of these types on x64.

Good luck,

mm

Maxim S. Shatskih wrote:

You can, but you must surround your FP work with
KeSave/RestoreFloatingPointState, otherwise, you will damage the FPU context of
some user app.