为什么在没有锁定的地方存在争用? [英] Why there are contentions in places with no lockings?

查看:86
本文介绍了为什么在没有锁定的地方存在争用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2010中运行软件的并发配置文件,发现不在锁内的代码行存在某些争用.说,一个新的操作来创建一个数组,或者一个线程本地的DynamicMethod.Invoke调用.一些争论只是关于简单的任务.我不知道为什么这些行会引起意图,因为在我的代码中,它们绝对不可能处于任何锁定状态.

I run a concurrency profile of a software in Visual Studio 2010 and found some contentions on lines of code that are not within locks. Say, a new operation to create an array, or a thread-local DynamicMethod.Invoke call. Some contentions are on simply assignments. I could not figure out why these lines cause intentions because there should be no way they are under any lockings in my code.

有人遇到类似的问题吗?我认为VS2010并发分析器中显示的争用均应由等待锁或进入互斥体部分引起.谢谢.

Anyone experiences similar problems? I think the contentions displayed in VS2010 concurrency profiler should all be caused by waiting on a lock or entering a piece of mutex section. Thanks.

推荐答案

新建一个数组并增加动态方法的使用量都会分配内存,因此有可能只是分配器中的争用吗?当然,这并不能解释任务线...

Newing an array and jitting your dynamic method would both allocate memory, so is it possible that it's just contention in the allocator? Of course, that doesn't explain the assignment lines...

这篇关于为什么在没有锁定的地方存在争用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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