Share via

Question about EnableThreadProfiling and ReadThreadProfilingData

Issam Khalil 6 Reputation points
2021-01-21T17:26:06.883+00:00

Hi,

When using ReadThreadProfilingData (https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-readthreadprofilingdata), for the hardware counter data the documentation is not clear how the OS handle the thread being interrupted and/or moving between cores.

Is this just a way to read the current counter value on the core the hardware is running on? Or is this really a per-thread counter?

Windows development | Windows API - Win32
0 comments No comments

1 answer

Sort by: Most helpful
  1. Drake Wu - MSFT 996 Reputation points
    2021-01-22T02:13:59.18+00:00

    Hi @Issam Khalil ,

    Is this just a way to read the current counter value on the core the hardware is running on? Or is this really a per-thread counter?

    According to another function EnableThreadProfiling:

    To profile hardware performance counters, you need a driver to configure the counters. The performance counters are configured globally for the system, so every thread has access to the same hardware counter data. The counters must be configured before you enable profiling. For information on configuring hardware performance counters, see the KeSetHardwareCounterConfiguration function in the Windows Driver Kit (WDK).


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.