Floating Point Support
wRTOS provides floating point support by saving all floating-point registers when necessary. There is no extra work required to support floating point. When an RTSS floating point operation is encountered in the kernel, an EXCEPTION_NPX_NOT_AVAILABLE (displayed as exception 7 in the TimeView log) is thrown and a wRTOS exception handler turns on the FPU (Floating Point Unit). This allows floating point operations to be performed in the currently executing thread. This exception should only occur once while a thread is actively executing. For instance, if the thread contains two back-to-back floating point operations, only the first operation will cause this exception. The FPU will already be enabled for the second. If there is a context switch, and the thread loses control of the processor, the FPU will be switched back off. The next time this thread is allowed to run, and a floating-point operation is encountered, an exception will again be generated to enable the FPU.
Moving Threads Using Floating Point
Threads using floating-point registers can be moved from one processor to another (see Moving Threads) until the first call using floating-point is made, after which they cannot be moved again.
Enabling Floating-Point Support in RTSS Programs
No special action is required to enable floating-point unit (FPU) support within your application. However, you should include the Microsoft C Runtime libraries to include the floating-point math routines and printf with floating-point support. If you are using the Microsoft Visual Studio wRTOS Application template, follow the procedure to enable Microsoft C Runtime support, as described in the Developing Applications with Visual Studio topic.
Note: Depending Visual Studio version, floating-point settings can impact API performance. wRTOS uses the /fp:precise compiler flag, which may affect determinism for some APIs, such as log or sin. For more information, see the Microsoft documentation on /fp (Specify floating-point behavior).
Running RTSS Programs Using Floating-Point
You do not need to follow any special procedures to run an RTSS program that uses floating-point. The program can simply issue floating-point unit (FPU) instructions and call them floating-point math routines, as done by a standard Win32 program.
Related topics: