OSDev.org
https://forum.osdev.org/

Fixed-Point OS
https://forum.osdev.org/viewtopic.php?f=15&t=55244
Page 1 of 1

Author:  PavelChekov [ Sat Oct 02, 2021 10:35 am ]
Post subject:  Fixed-Point OS

Pretty much every complete OS I've seen initializes floating point units, but would it be possible to make an OS that uses fixed-point arithmetic?

Thanks

Author:  Korona [ Sat Oct 02, 2021 11:20 am ]
Post subject:  Re: Fixed-Point OS

Fixed point and floating point calculations often have different purposes. Even mainstream OSes use fixed point calculations for some purposes. For example, fixed point calculations can be useful when dealing with running times of processes (which are typically in a range between some microseconds to a few months; for example, POSIX' struct timespec is essentially a fixed point representation for times), while floating point calculations are useful if accuracy is needed over a range that spans many orders of magnitude.

Author:  alexfru [ Sat Oct 02, 2021 1:58 pm ]
Post subject:  Re: Fixed-Point OS

Old x86 PCs didn't always have an x87 chip installed and many compilers of the time came with floating point emulation in their libraries (that is, either x87 instructions were never generated and instead replaced by calls to the library to perform addition, multiplication, etc or they were intercepted (on 80286+ or 80386+)).

Your OS itself may do something similar. However, if it needs to support floating point in user programs, it needs to be able to save and restore the FPU context (nowadays, it's pretty fat: many long AVX registers and some control/status regs as well). It can, however, intercept FPU instructions as well.

Author:  Octocontrabass [ Sat Oct 02, 2021 3:05 pm ]
Post subject:  Re: Fixed-Point OS

Yes, it's possible to make an entire OS that doesn't use any floating-point arithmetic.

Why don't you want to initialize the FPU? Even if you don't use the FPU anywhere in your OS, you might want to initialize it for usermode programs.

Author:  zaval [ Sat Oct 02, 2021 4:18 pm ]
Post subject:  Re: Fixed-Point OS

Octocontrabass wrote:
Why don't you want to initialize the FPU? Even if you don't use the FPU anywhere in your OS, you might want to initialize it for usermode programs.

he just likes to create threads about pretty much everything, he doesn't want to do his own re/search on. :mrgreen:

Author:  PavelChekov [ Sun Oct 03, 2021 11:19 am ]
Post subject:  Re: Fixed-Point OS

I am still going to use floating-point in my OS, I was just curious. Some microcontrollers don't have floating point support.

Author:  Ethin [ Mon Oct 04, 2021 9:05 am ]
Post subject:  Re: Fixed-Point OS

In that case, you'd emulate floating-point operations.

For x86, you should probably just initialize SSE/AVX (I'm pretty sure that most compilers will nowadays translate FP operations to SSE/AVX operations and not x87 FP ops).

Author:  rdos [ Tue Oct 05, 2021 9:45 am ]
Post subject:  Re: Fixed-Point OS

I don't see much of a reason why an OS would need to use floating point. Mine certainly doesn't. Floating point is mostly for user programs.

Author:  rdos [ Tue Oct 05, 2021 9:49 am ]
Post subject:  Re: Fixed-Point OS

Ethin wrote:
In that case, you'd emulate floating-point operations.

For x86, you should probably just initialize SSE/AVX (I'm pretty sure that most compilers will nowadays translate FP operations to SSE/AVX operations and not x87 FP ops).


Regardless if that is true or not, the OS will still need to save x87 and support the use of x87 FP ops. There is no guarantee that an application will not use x87 FP ops.

My design only supports x87 FP ops, and I only save that state, which is not currently a problem since OpenWatcom doesn't use SSE or AVX, and it is the only supported compiler. Makes for faster FP state saving too.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/