Counting the number of context switches in a c program when that program is executed

1.1k Views Asked by At

I want to output the number of context switches that are performed by the windows OS while executing my program.

1

There are 1 best solutions below

0
On

You can use Performance-counter for this purpose.

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

You can view context switch data in two ways:

  • The System\Context Switches/sec counter in System Monitor reports systemwide context switches.
  • The Thread(_Total)\Context Switches/sec counter reports the total number of context switches generated per second by all threads.