0

I need to check context switches for thread. I'm writing function, that return context switches from thread id. I'm computing context switch counts using the PDH library. I can get the thread context switch count for all threads using this construction:

Status = PdhAddCounter(Query, resultBuffer, NULL, &Counter);

where resultBuffer is "Thread(_Total/_Total)\\Context Switches/sec"

What do I have to change (_Total/_Total)?

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
Alexander Mashin
  • 693
  • 3
  • 14
  • 34

1 Answers1

1

Some playing around with perfmon suggests that the format should be

Thread(<process name>/<thread id>)\\Context Switches/sec

The thread ID you already have; you can get the process name from the process ID using the answers to this question.

Community
  • 1
  • 1
Eric Brown
  • 13,774
  • 7
  • 30
  • 71