.Net Profiler-从Profiler获取线程状态 [英] .Net Profiler - Getting thread status from Profiler

查看:98
本文介绍了.Net Profiler-从Profiler获取线程状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了事件掩码 " COR_PRF_MONITOR_SUSPENDS"& " COR_PRF_MONITOR_THREADS"要得到 线程创建和销毁回调. 

I have set event masks  "COR_PRF_MONITOR_SUSPENDS" & "COR_PRF_MONITOR_THREADS" to get the thread creation and destroy callbacks. 

我从ThreadContext_start函数为每个线程形成堆栈跟踪,直到达到"FunctionEnter"的某个深度为止.钩子.

通过某种方式,我可以考虑线程创建和cpu时间等.我需要获取线程等待状态. ;

我会说一个测量周期内正在运行的线程和已完成的线程.我怎么说呢?

当线程在C#中进入等待状态时? (猜猜它何时入睡以及何时等待通知)

有RuntimeSuspend回调,但我没有收到该回调.如果线程进入等待状态,还有什么其他方法呢?

推荐答案

RuntimeSuspend */RuntimeResume *回调用于当整个运行系统被挂起/恢复时(例如,对于GC),它不报告单个线程何时进入/离开等待状态.

The RuntimeSuspend*/RuntimeResume* callbacks are for when the runtime as a whole is suspended/resumed (eg. for GC), it's not reporting when individual threads enter/leave the waiting state.

我相信CLR会通过一个核心功能将大多数阻塞操作归纳为支持 SynchronizationContext.Wait ;因此至少从理论上讲,它可以为那些触发器提供通知.但是,如果某个线程因某个原因(例如,阻塞了本机方法而阻塞)而阻塞,则CLR将无法报告该线程.因此,如果提供了运行时 这样的回调将是不完整的,并且可能会产生误导.

I believe the CLR funnels most blocking operations through a core function in order to support SynchronizationContext.Wait; so in theory at least, it could provide notifications for those triggers. However if a thread blocks because it, say, pinvoked a native method that blocks, then the CLR would be unable to report it. So if the runtime provided such a callback, it would be incomplete and potentially misleading.

也许有一种方法可以通过win32获取此信息,但我不希望它在进程内起作用.

Maybe there is a way to get this information through win32, but I wouldn't expect it to work in-process.


这篇关于.Net Profiler-从Profiler获取线程状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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