<p>Are you talking about the <code>CCriticalSection</code> class?  As you can see in <code>sync.h</code>, it's just a wrapper around Boost's <code>recursive_mutex</code> class.  (It looks like the <code>CCriticalSection</code> name comes from Windows.)</p>

<p>You can read all about Boost's threading API in <a href="http://www.boost.org/doc/libs/1_56_0/doc/html/thread.html" rel="nofollow">its documentation</a>.</p>

CC BY-SA 3.0
2014-08-24T22:00:37.277Z
It is more clear now. But is CCriticalSection class related to CRITICAL_BLOCK? Also, what does the cs mean in cs_mapKeys?
user1769523
CC BY-SA 3.0
2014-08-24T22:05:25.077Z
@user1759523: I don't know what CRITICAL_BLOCK is and I see no reference to it in the Bitcoin source. cs is just part of the name of the variable ´cs_mapKeys´ but I assume it is supposed to remind you that it is an object of type CCriticalSection.
Nate Eldredge
CC BY-SA 3.0
2014-08-24T22:41:07.680Z
Maybe it was only in previous versions. See: https://github.com/bitcoin/bitcoin/blob/4405b78d6059e536c36974088a8ed4d9f0f29898/main.cpp
user1769523
CC BY-SA 3.0
2014-08-24T23:53:59.813Z
@user1759523: It looks like this has been replaced by LOCK. But anyway, you can see the code in sync.h; I'm not sure what you want to know specifically. These might be better questions for Stack Overflow since they are more about C++ in general than Bitcoin in particular.
Nate Eldredge
CC BY-SA 3.0
2014-08-24T17:52:19.377Z
2014-08-24T17:52:19.377Z
Nate Eldredge
<p>Can you please point me to a tutorial for an explanation of the specific "Critical section" implementation that is used in main.cpp. I would like to understand a bit better how does it work. I studied concurrency before so I have some background to be able to understand it.</p>

<client>
Critical Section in Satoshi client
user1769523
# Critical Section in Satoshi client

(Asked by: username_0 on 2014-08-24)

Can you please point me to a tutorial for an explanation of the specific "Critical section" implementation that is used in main.cpp. I would like to understand a bit better how does it work. I studied concurrency before so I have some background to be able to understand it.

**Tags:** client


---

## 1 answers

### Answer by username_1 on 2014-08-24. Score: 1

Are you talking about the `CCriticalSection` class? As you can see in `sync.h`, it's just a wrapper around Boost's `recursive_mutex` class. (It looks like the `CCriticalSection` name comes from Windows.)

You can read all about Boost's threading API in [its documentation](http://www.boost.org/doc/libs/1_56_0/doc/html/thread.html).

> **Comments:**
> **username_0**: It is more clear now. But is CCriticalSection class related to CRITICAL_BLOCK? Also, what does the cs mean in cs_mapKeys?  
> **username_1**: @user1759523: I don't know what CRITICAL_BLOCK is and I see no reference to it in the Bitcoin source. cs is just part of the name of the variable ´cs_mapKeys´ but I assume it is supposed to remind you that it is an object of type CCriticalSection.  
> **username_0**: Maybe it was only in previous versions. See: https://github.com/bitcoin/bitcoin/blob/4405b78d6059e536c36974088a8ed4d9f0f29898/main.cpp  
> **username_1**: @user1759523: It looks like this has been replaced by LOCK. But anyway, you can see the code in sync.h; I'm not sure what you want to know specifically. These might be better questions for Stack Overflow since they are more about C++ in general than Bitcoin in particular.  

---

