Поделиться через


Setting Up Monte Carlo Profiling (Windows Embedded CE 6.0)

1/5/2010

To perform Monte Carlo profiling by using the kernel profiler, the OAL must implement an interrupt for the kernel profiler. Each BSP provided with Platform Builder implements this interrupt. If you use a custom BSP, you may need to implement this interrupt in the OAL.

Note

The kernel profiler can perform system call profiling and instrumented kernel profiling without support for an interrupt for the kernel profiler. For more information about the modes of the kernel profiler, see Kernel Profiler Modes.

The interrupt for the kernel profiler calls the ProfilerHit function, which takes each profiling sample. For information about the process by which the kernel profiler identifies a profiling sample, see Buffered and Unbuffered Profiling. The OAL must periodically call the ProfilerHit function, typically from a periodic ISR. An application cannot call the ProfilerHit function.

To set up Monte Carlo Profiling

  1. Implement in the OAL the OEMProfileTimerDisable and OEMProfileTimerEnable functions that disable and enable the interrupt for the kernel profiler.

    The kernel calls the OEMProfileTimerEnable function when the kernel profiler starts and calls the OEMProfileTimerDisable function when the kernel profiler stops. The OEMProfileTimerDisable function clears and disables the timer for the kernel profiler. The OEMProfileTimerEnable function enables and starts the timer for the kernel profiler.

    The simplest method to set up Monte Carlo profiling is to enable the high-resolution timer in OEMProfileTimerEnable if one is available for the BSP. If a high-resolution timer is not available, you must modify OEMIdle as described in step 3.

    If a high resolution timer is not available, you can enable the timer used for the system tick. You must change the system tick frequency to a higher frequency that is required by the profiler.

  2. Implement an ISR for the kernel profiler by calling the ProfilerHit function to record each profiler hit.

    If you are using a high-resolution timer, call ProfilerHit when an interrupt from this timer occurs. If you are not using a high-resolution timer, use the system tick interrupt to call this API.

    The value you pass to ProfilerHit must be the same value passed to OEMInterruptHandler. This value is the instruction counter when the interrupt occurred.

  3. If necessary, implement the OEMIdle function to correctly handle the case when the profiler is running.

    OEMIdle does not need to be modified unless you are using the same timer used for the system tick. If you are using a high-resolution timer, this API does not need to be modified. In modifications to this API, you must determine that the profiler is running, then skip the tasks that it normally performs, such as re-programming the timer.

  4. Verify that the Config.bib file sets PROFILE=ON in the MEMORY section if the IMGPROFILER environment variable is set.

    When you set this PROFILE=ON, Makeimage is instructed to add information required for Monte Carlo profiling into the run-time image.

    For more information, see Configuring the Config.bib and Common.bib Files for IMGPROFILER.

  5. Build a run-time image that supports the kernel profiler.

    For more information, see Building a Run-Time Image That Supports the Kernel Profiler.

    As an additional optional step, you can also implement a way to control the kernel profiler before building the run-time image. For example, you can control the profiler by calling the ProfileStart and ProfileStop functions. For more information, see Controlling the Kernel Profiler by Using the Profiler API.

See Also

Concepts

Setting Up the Kernel Profiler
Kernel Profiler Modes