On Time RTOS-32 Documentation
Welcome
RTTarget-32
RTKernel-32
RTKernel-32 Programming Manual
Introduction
Multitasking, Real-Time, and RTKernel-32
Module RTKernel-32
Alternate APIs for RTKernel-32
Supplemental Modules
RTKernel-32 Drivers
Demo Programs
Advanced Topics
RTKernel-32's Debug Version
How to Create Threads
Interrupt Handling
Avoid Polling
Preemptive or Cooperative Multitasking?
Waiting for Several Events
Avoid Large Message Types
Mutual Exclusion
Avoid Time Slicing
Cyclic Tasks (Timer)
Priorities
Starting Objects' Methods as Tasks
Performance and Interrupt Response Times
Multiprocessor Applications
OpenMP
Task Switches in Cooperative Scheduling
Writing Custom Kernel Drivers
Using the FPU in Interrupt Handlers
Typical Error Sources
Error and Information Messages
RTKernel-32 Reference Manual
RTFiles-32
RTIP-32
RTPEG-32
RTUSB-32
|
OpenMP
The OpenMP (http://www.openmp.org/) Application Program Interface (API) supports multi-platform shared-memory parallel programming in C/C++ and Fortran. OpenMP is a portable, scalable model that gives programmers a simple and flexible interface for developing shared-memory parallel applications.
Visual Studio 2005/2008/2010/2012/2013's OpenMP support can be used with On Time RTOS-32, as demonstrated by demo program OMPrimes. Here are the steps required to use OpenMP:
- The program must be linked with the multiprocessor kernel, as described in previous section Multiprocessor Applications.
- If the application uses floating point, the floating point driver Fltpii.lib should be linked before Drvrt32.lib and RTKConfig flag RF_FPCONTEXT should be set.
- Visual Studio's OpenMP support relies on DLL Vcomp.dll/Vcomp90.dll/Vcomp100.dll/Vcomp110.dll/Vcomp120.dll/Vcomp140.dll (or Vcompd.dll/Vcomp90d.dll/Vcomp100d.dll/Vcomp110d.dll/Vcomp120d.dll/Vcomp140d.dll for the debug run-time system). This DLL must be copied into the project directory and located in the RTLoc configuration file.
- The main program (or the system DLL, if the application has one) must export the Win32 API required by Vcomp[90|100|110|120|140][d].dll. This can be achieved by copying file OMPrimes.def from demo program OMPrimes and specifying it on the program's linker command line using linker option /DEF. Alternatively, such a .def file can be generated with program MakeDef.
- Vcomp[90|100|110|120|140][d].dll's initialization code needs a lot of stack space. The program's stack should have at least 48k. The stack size is specified with the "Locate Stack ..." directive in the RTLoc configuration file.
- If the time measurement functions of OpenMP (such as omp_get_wtime()) are to be used, RTKernel-32's high resolution timer driver must be calibrated in an Init routine using function FTSetResolution. This is required because Vcomp[90|100|110|120|140][d].dll's initialization code calls QueryPerformanceFrequency before the main .exe has been initialized and RTKernelInit has been called.
An application has no control over how the OpenMP run-time system creates threads. Therefore, it is important to set RTKConfig flag RF_FPCONTEXT and link Fltpii.lib if any parallel code sections can execute floating point code. OpenMP uses the default stack size and default priority, both of which can be set in RTKConfig.
Advanced Topics
Multiprocessor Applications
Task Switches in Cooperative Scheduling
|