Pifcnt
Pifcnt

Reputation: 117

Large number of critical sections

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 lock 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.

Upvotes: 2

Views: 768

Answers (1)

user180326
user180326

Reputation:

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.

Upvotes: 3

Related Questions