What are gcc on linux's equivalent to microsoft's critical sections?
<p>The Microsoft Visual C++ compilers have the <code>EnterCriticalSection</code> and <code>ExitCriticalSection</code>
objects to allow for synchronization between threads.</p>

<p>What is the GCC equivalent?</p>

<p>I see references around to <code>__sync_synchronize</code> along with <code>__scoped_lock</code></p>

<p>In fact I see mention of a number of atomic <code>__sync</code> functions along with a number of
<code>__atomic</code> ones.</p>

<p>I actually have been using <code>__sync_fetch_and_add</code> for my atomic increment
Should I be using <code>__atomic_add_dispatch</code> instead?<br>
What's the difference?</p>

<p>Which ones should I be using?  Are there some constructs in C++ that I can use in both the latest version of GCC and Visual C++ 2010 that are available as I'm going to be writing some cross platform code.</p>

<p>I see boost has some functions available, but for various reasons I'm not allowed to use boost under windows.</p>
