[previous] [index] [next]

Example 12: Floating Point in Real-Time Tasks

This example demonstrates how to use floating-point math in real-time tasks. Aside from loading the RT Linux math library, which is done in the usual "insrtl" script along with support for scheduling, FIFOs, etc., you need to signify that you want the floating point unit (FPU) registers to be saved and restored by RT Linux. Otherwise, these are left alone, and the use of the FPU by an RT task will clobber the floating point calculations of any Linux program. This is never desirable behavior, so always make sure to enable FPU save/restore in your RT task if you use floating point.

Refer to the commented real-time source code and the commented application source code for the details.

Principle of Operation

Running the Demo

To run the demo, change to the 'ex12_math' subdirectory of the top-level tutorial directory, and run the 'run' script by typing
./run
Alternatively, change to the top-level tutorial directory and run the 'runall' script there by typing
./runall
and selecting the "Floating Point" button.

You'll see diagnostics messages printing out.

See the Real-Time Task Code

See the Linux Application Code


Next: Acknowledgements

Back: Example 11, Measuring Timing Jitter