Partager via


Hardware-Assisted Profiling

Windows CE supports hardware-assisted profiling by including an application programming interface (API) library that supports process-level tracking. You can use this library to write an application that can be notified when a process or thread is created or terminated, or when a thread is scheduled to run.

Process-level tracking enables an OEM to be notified when a process or thread is created, terminated or (in the case of a thread) scheduled. The information passed to the OEM can be used to perform additional functionality, such as profiling.

To enable the process and thread notifications, assign addresses to the following global function pointers in the OAL. Nk.lib exports these global variables. If the variables are defined and valid, the kernel calls the functions pointed to by these variables. The recommended practice is to assign the variables in the OEMInit function. You can do so at any time.

The following table shows the global variables that support process-level tracking.

Global variable Description
pLogThreadCreate Points to the LogThreadCreate function that you implement.
pLogThreadDelete Points to the LogThreadDelete function that you implement.
pLogProcessCreate Points to the LogProcessCreate function that you implement.
pLogProcessDelete Points to the LogProcessDelete function that you implement.
pLogThreadSwitch Points to the LogThreadSwitch function that you implement.

The following table shows the functions that support process-level tracking.

Function Description
LogProcessCreate Logs information when a process is created.
LogProcessDelete Logs information when a process is terminated.
LogThreadCreate Logs information when a thread is created.
LogThreadDelete Logs information when a thread is terminated.
LogThreadSwitch Logs information when a thread is scheduled to run.

Previous versions of Platform Builder provided a set of UserLog* APIs that served as wrappers for the tracking functions. These APIs are no longer supported. However, the following functions remain in Schedlog.lib.

Function Description
SchedLogTranslate Converts a thread or process identifier to a Windows CE object handle.
SchedLogGetProcessName Retrieves the name of a process.
SchedLogGetThreadProgramCounter Retrieves the program counter for a thread.

To build Schedlog.lib functionality into the kernel and update the OS image

  1. Set the following environment variables from the command line of the Build window for the target project:

    • SCHEDLOG

      Define this environment variable by typing the following command line:

      set SCHEDLOG=1
      

      This causes Schedlog.lib to be linked to the kernel, Nk.exe.

    • WINCEREL

      Define this environment variable by typing the following command line:

      set WINCEREL=1
      

      This causes built binary files to be copied to the %_FLATRELEASEDIR% directory. It provides a convenient way to update Nk.exe in the release directory without copying it manually or running Buildrel.bat.

  2. Build the kernel for the target device.

    For example, navigate to the %_WINCEROOT%\Platform\Cepc\Kernel directory and type the following command line:

    build -cfs
    
  3. Run Makeimg.exe, which rebuilds Nk.bin to include Schedlog.lib in Nk.exe.

 Last updated on Friday, October 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.