User`s guide

10 Interrupts Versus Polling
10-6
The model is optimal concerning execution speed — First, you should run
the model through the Simulink profiler to find any possible speed
optimizations using alternative blocks. If the model contains continuous
states, the discretization of these states will reduce model complexity
significantly, because a costly fixed-step integration algorithm can be
avoided. If continuous states cannot be discretized, you should use the
integration algorithm with the lowest order that still produces correct
numerical results.
Use the fastest available computer hardware Ensure that the CPU
with the highest clock rate available is used for a given PC form factor. For
the desktop form factor, this would mean a clock rate above 1 GHz; for a
mobile application, e.g., using the PC/104 form factor, this would mean a
clock rate above 400 MHz. Most of the time, you should use a desktop PC,
because the highest clocked CPUs are available for this form factor only.
Executing
xpcbench at the MATLAB prompt gives an understanding about
the best performing CPUs for xPC Target applications.
Use the lowest latency I/O hardware and drivers available — Many xPC
Target applications communicate with hardware through I/O hardware over
either an ISA or PCI bus. Because each register access to such I/O hardware
introduces a comparably high latency time (~1 µs), the use of the lowest
latency hardware/driver technology available is crucial.
The base sample time is about 50 µs or less — The time additionally
assigned to model code execution in polling mode is only about 8 µs. If the
given base sample time of the target application exceeds about 50 µs, the
possible percentage gain is rather small. Other optimization technologies
might have a bigger impact on increasing performance.
Setting the Polling Mode
Polling mode is an alternative to the default interrupt mode of the real-time
kernel. This means that the kernel on the bootable 3.5 inch disk created by the
xpcexplr GUI allows running the target application in both modes without the
necessity to use another boot disk.
By default the target application executes in interrupt mode. To switch to
polling mode, you need to pass an option to the
RTW system target file
command. The following example uses
xpcosc.mdl.