我可以创建多少个关键部分有任何限制? [英] There is any limit on how many critical section i can create?

查看:90
本文介绍了我可以创建多少个关键部分有任何限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在多个线程上访问的类.

i have a Class that can be accessed on multiple thread.

为确保我没有同时访问权限,我将使用CCriticalSection

To make sure i don't have simultaneous access i will use a CCriticalSection

我想知道是否可以为对象的任何副本创建CCriticalSection(我认为我在程序中可以拥有约100-1000个该对象),还是最好创建一个静态成员CCriticalSection并将其用于所有对象该对象?

I was wondering if i can just create a CCriticalSectionfor any copy of the object (i think i can have about 100-1000 this object in the program) or it will be best to create a static member CCriticalSection and use this for all the object?

推荐答案

在XP/Server 2003之前,您可能用尽了CRITICAL_SECTION的内核对象(特别是当).对于XP及更高版本,您受虚拟地址空间的束缚,就像处理许多事情一样.

Prior to XP/Server 2003 you could run out of kernel objects for CRITICAL_SECTIONs (specifically the event used to arbitrate when there was contention on the CRITICAL_SECTION). For XP and beyond you're bounded as you are for many things, by your virtual address space.

这篇关于我可以创建多少个关键部分有任何限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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