线程的上下文切换(C ++ Windows) [英] Context switches of thread (C++ windows)

查看:497
本文介绍了线程的上下文切换(C ++ Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我知道线程的HANDLE,如何知道c ++中的上下文切换"计数?

How can I know "Context Switches" count with c++, if I know HANDLE of thread?

http://i.stack.imgur.com/MYDa2.jpg

推荐答案

  1. 通过使用以下一种API查询名为Thread(<process-name>/<thread-number>)/Context Switches/sec的性能计数器在C ++中访问性能数据.有关此内容的更多信息:如何以编程方式计算上下文切换?

  1. By querying perofrmance counters named Thread(<process-name>/<thread-number>)/Context Switches/sec using one of the APIs, e.g. Accessing Performance Data in C++. More on this: how programmatically count context switches?

使用Windows内部以编程方式获取线程上下文开关的数量 /代码段.

Using Windows internal NtQuerySystemInformation API, see Obtaining number of thread context switches programmatically for details/code snippet.

特别是在谈论Process Explorer时,我猜是它正在从NtQuerySystemInformation中获取数据.

Talking about Process Explorer in particular, my guess would be it's taking data from NtQuerySystemInformation.

这篇关于线程的上下文切换(C ++ Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆