windows windows中每个进程/线程的最大互斥量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3714935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
maximum number of mutexes per process/thread in windows
提问by mas_oz2k1
Is there a limit in the maximum number of mutexes per process/thread in a Asp.net application?
Asp.net 应用程序中每个进程/线程的最大互斥量是否有限制?
Just in case the target operating systems are: Windows XP Pro, server 2003/2008 and Windows 7 in the near future. Usually the website is deployed in an App Pool.
以防万一目标操作系统是:Windows XP Pro、服务器 2003/2008 和 Windows 7 在不久的将来。通常,网站部署在应用程序池中。
回答by paxdiablo
I'm going to go out on a limb here and venture the possibility that you're probably(not necessarily) doing something wrong.
我要在这里冒险一下,冒险一下你可能(不一定)做错了什么。
Raymond Chen said it bestbut, if you're worried about the maximum number of mutexes, you're probably protecting your resources at too fine a granularity.
Raymond Chen 说得最好,但是,如果您担心互斥体的最大数量,那么您可能会以太细的粒度保护您的资源。
Certainly there willbe a maximum number even if it's dictated by available memory rather than a constant. However, I can't see any valid situation in which you would need so many mutexes that you would hit a limit.
当然,即使它是由可用内存而不是常数决定的,也会有一个最大数量。但是,我看不到任何有效的情况,在这种情况下,您需要如此多的互斥锁以致达到限制。
I'm not saying it's not possible since I have no idea what the architecture of your application is. But I would be very surprised if there wasn't a better way to do it.
我并不是说这是不可能的,因为我不知道您的应用程序的架构是什么。但如果没有更好的方法来做到这一点,我会感到非常惊讶。
Perhaps if you step back and tell us the "what I want" rather than the "how I did it", we could offer better advice.
也许如果你退一步告诉我们“我想要什么”而不是“我是如何做到的”,我们可以提供更好的建议。
回答by wj32
The limit is essentially the same as the limit on the number of handles a process can have. It's quite a big number: 16,777,216. Of course, the real limit is much lower, and depends on how much non-paged pool you have available, which isn't that big.
该限制本质上与进程可以拥有的句柄数量限制相同。这是一个相当大的数字:16,777,216。当然,真正的限制要低得多,取决于您有多少可用的非分页池,这不是那么大。
If you're worried about the limit, there's something wrong with your program. Keep in mind that critical sections usually delay the creation of any kernel objects, which means you can have a large number of them if there are few contentions.
如果您担心限制,则说明您的程序有问题。请记住,临界区通常会延迟任何内核对象的创建,这意味着如果争用很少,您可以拥有大量它们。