Share via


Implementing Profiler Timer Interrupts in the OAL (Compact 2013)

3/26/2014

In Windows Embedded Compact 2013, OAL support for profiler timer interrupts is not required in order to use the kernel profiler in Monte Carlo mode. To use the profiler in Monte Carlo mode, the OAL can implement an optional interrupt, or use a method known as tick-based profiling.

In tick-based profiling, the profiler instead uses other system interrupts, such as SYSINTR_NOP, to record profiler hits. You might need to implement the system interrupts in the OAL if it is not already implemented. Tick-based profiling does not guarantee regularly timed profiler interrupts, and typically collects samples at a lower frequency than a true profiler interrupt implementation.

While OAL implementation of the profiler timer interrupt is optional, implementation is still recommended because with this method, you can configure profiler sampling to use well-controlled time intervals. This improves the timer accuracy and increases the frequency of the profiler interrupts.

The optional OAL support for profiler interrupts operates as follows: The OAL calls the ProfilerHit function, typically from a periodic ISR. ProfilerHit records each profiling sample. An application cannot call the ProfilerHit function.

To implement profiler timer interrupts in the OAL

  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. In the function OEMInit, set pointers to OEMProfileTimerEnable and OEMProfileTimerDisable using the following syntax.

    g_pOemGlobal->pfnProfileTimerEnable = OEMProfileTimerEnable;
    g_pOemGlobal->pfnProfileTimerDisable = OEMProfileTimerDisable;
    
  3. 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.

  4. 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.

See Also

Concepts

Setting up the Kernel Profiler