Floating Point Support

RTX provides floating point support by saving all floating-point registers. The registers can easily be saved since RTSS processes run in kernel mode. This allows developers to use floating point functionality as if in a user mode application. This is different from Windows, which does not support floating point use and does not save floating-point registers. Developers who code traditional kernel mode applications typically save and restore the state of floating point registers between FPU usages.

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 an RTX 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 floating point operations back-to-back, only the first floating point 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

On dedicated systems, 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.

Enabling Floating-Point Support in RTSS Programs

To enable floating-point unit (FPU) support within your application no special action is required. 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 Microsoft Visual Studio, follow the procedure to enable C run-time support as described in Using the RTX Application Template.

NOTE:  Depending on the version of Visual Studio you use, floating-point settings can have an impact on API performance. The MSDN article "Microsoft Visual C++ Floating-point Optimization" explains the compiler flags available.

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 floating-point math routines as done by a standard Win32 program.

 

See Also

IntervalZero.com | Support | Give Feedback