OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 2:13 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Fixed-Point OS
PostPosted: Sat Oct 02, 2021 10:35 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 100
Location: Aboard the Enterprise
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

_________________
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Sat Oct 02, 2021 11:20 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
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].


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Sat Oct 02, 2021 1:58 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
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.


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Sat Oct 02, 2021 3:05 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
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.


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Sat Oct 02, 2021 4:18 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
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:

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Sun Oct 03, 2021 11:19 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 100
Location: Aboard the Enterprise
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!
Слава Україні!


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Mon Oct 04, 2021 9:05 am 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
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).


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Tue Oct 05, 2021 9:45 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3180
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.


Top
 Profile  
 
 Post subject: Re: Fixed-Point OS
PostPosted: Tue Oct 05, 2021 9:49 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3180
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group