How to count context switches programmatically?

前端 未结 2 1257
自闭症患者
自闭症患者 2021-01-21 03:58

Under windows, is there anyway to programmatically count context switches of the same process? The best thing is a callback that gets called whenever a thread is switched.

2条回答
  •  抹茶落季
    2021-01-21 04:20

    There's a performance counter that does the work for you. All you have to do is read its value. You can find a description on how to do it interactively here, but performance counters can also be consumed using their API.

提交回复
热议问题