.NET 锁定性能计数器差异
“.NET CLR LocksAndThreads”类别中的“争用总数”和“队列长度峰值”窗口性能计数器有什么区别? MSDN 文档可在此处获取:http://msdn.microsoft.com/en-us /library/zf749bat.aspx。
我认为我的困惑在于“尝试获取锁失败的线程数”与“自应用程序启动以来等待获取托管锁的线程总数”之间的差异。从本质上讲,等待获取锁(我将其解释为当您尝试获取锁时其他人正在持有它)与尝试获取锁失败之间有什么区别?我唯一能想到的与如何尝试锁定获取有关,例如 Monitor.TryEnter 与 Monitor.Enter。
What is the difference between the "Total # of Contentions" and "Queue Length Peak" windows performance counters in the ".NET CLR LocksAndThreads" category? MSDN Documentation is available here: http://msdn.microsoft.com/en-us/library/zf749bat.aspx.
I think my confusion is about the difference between "the number of threads that tried to acquire a lock unsuccessfully" vs "the total number of threads that waited to acquire a managed lock since the application started." In essence, what is the difference between waiting to acquire a lock, which I interpret as meaning someone else is holding it when you try to acquire it, and trying to acquire a lock unsuccessfully?? The only thing I can think of would be related to how lock acquisition is attempted, e.g. Monitor.TryEnter vs. Monitor.Enter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当尝试获取锁时我会想到 3 种情况:
a) 资源没有被其他实体锁定,立即获取
b) 资源被锁定,但按时释放,延迟获取
c) 资源被锁定,但未按时释放,获取超时
争用总数 - 场景总数 (c)
队列长度峰值 - 在任何给定时间处于状态 (b) 的线程最多
I would think of 3 scenarios when trying to acquire lock:
a) resource no locked by other entity, acquired immediately
b) resource locked, but released on time, acquired with delay
c) resource locked, but not released on time, acquisition times out
Total # of Contentions - total of scenario (c)
Queue Length Peak - at any given time the most threads in state (b)