开发者

Large number of critical sections

开发者 https://www.devze.com 2023-02-06 02:06 出处:网络
Environment: C++,VS 2008, MFC, app for Windows XP. I have to access & modify a tree structure in 2 threads. My idea is to protect each node with an CCriticalSection that would lo开发者_C百科ck eac

Environment: C++,VS 2008, MFC, app for Windows XP. I have to access & modify a tree structure in 2 threads. My idea is to protect each node with an CCriticalSection that would lo开发者_C百科ck each and every time the node inner data (not child) gets accessed. I am expecting large number of nodes (2-300000).

Can the very large number of critical sections be a problem?

I heard that Windows has an issue with large numbers of open handles, that is why I am asking this.


Unlike mutexes, Critical sections are not kernel objects and only require an OS handle as soon as there is actual attempt by two threads to lock it. read this Matt Pietrek article if you want to know how it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消