Counting the number of context switches in program c while executing that program

I want to output the number of context switches that are executed by Windows OS during the execution of my program.

+3


source to share


1 answer


You can use a performance counter for this purpose.

From: http://msdn.microsoft.com/en-us/library/aa373083%28VS.85%29.aspx



You can view the context switch data in two ways:

  • System \ Context Switches / Seconds Count in System Monitor reports general context switches.
  • Topic (_Total) \ Context Switches / sec counter reports the total number of context switches generated per second by all threads.
+1


source







All Articles