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
Fixed-Point OS
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
Fixed-Point OS
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
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.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
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.
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.
-
- Member
- Posts: 5512
- Joined: Mon Mar 25, 2013 7:01 pm
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.
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.
Re: Fixed-Point OS
he just likes to create threads about pretty much everything, he doesn't want to do his own re/search on.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.
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
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.
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
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).
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).
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.
Re: Fixed-Point OS
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.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).
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.