<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Critical Section vs. Mutex</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx</link><description>Posted by Jeremy Cooke Both critical sections and mutex objects can be used to synchronize code execution in a Windows CE system. Judicious use of these techniques is necessary to prevent sharing conflicts over system resources through synchronized access.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Critical Section vs. Mutex</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx#1988970</link><pubDate>Thu, 29 Mar 2007 18:09:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1988970</guid><dc:creator>Dean Ramsier</dc:creator><description>&lt;p&gt;Nice posting on CS vs Mutexes. &amp;nbsp;One critical point that wasn't made clear is that critical sections only provide synchronization within a single process. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;While they do limit access to a section of code to a single thread, that is only true for the set of threads within a process. &amp;nbsp;If the code is in a dll that can be loaded by multiple processes, then multiple threads from different processes can take ownership of the CS simultaneously.&lt;/p&gt;
&lt;p&gt;- Dean&lt;/p&gt;
</description></item><item><title>re: Critical Section vs. Mutex</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx#1994614</link><pubDate>Fri, 30 Mar 2007 19:31:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1994614</guid><dc:creator>ce_base</dc:creator><description>&lt;p&gt;Dean,&lt;/p&gt;
&lt;p&gt;I just want to clarify one thing above. If the dll is loaded in multiple processes, then the critical section object is unique per process. So in reality even if multiple threads from different processes might be executing the same section of the code in the dll, they would be operating on per-process data (including the critical section object exposed by the dll).&lt;/p&gt;
&lt;p&gt;I hope that is what you meant by the statement that different processes can take ownership of the CS simultaneously. In that case the CS would be different for each process.&lt;/p&gt;
&lt;p&gt;thx.&lt;/p&gt;
&lt;p&gt;-Upender&lt;/p&gt;
</description></item><item><title>.NET Compact Framework: Mutex vs Critical Section</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx#2011027</link><pubDate>Mon, 02 Apr 2007 13:26:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2011027</guid><dc:creator>Ruslan Trifonov's blog</dc:creator><description>&lt;p&gt;What do you use for thread synchronization - mutex or critical section? Check out this blog post from&lt;/p&gt;
</description></item><item><title>re: Critical Section vs. Mutex</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx#2012990</link><pubDate>Mon, 02 Apr 2007 20:01:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2012990</guid><dc:creator>Mark Moeller</dc:creator><description>&lt;p&gt;Sue Loh's article on lock convoys is an important piece of information to reference after reading this article. &amp;nbsp;There is a dark side to the behavior of these helpfuls syncronization objects that needs to be understood and avoided. &amp;nbsp;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/sloh/archive/2005/05/27/422605.aspx#1266395"&gt;http://blogs.msdn.com/sloh/archive/2005/05/27/422605.aspx#1266395&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Critical Section vs. Mutex</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx#2013824</link><pubDate>Mon, 02 Apr 2007 22:38:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2013824</guid><dc:creator>Dean Ramsier</dc:creator><description>&lt;p&gt;Hi Upender,&lt;/p&gt;
&lt;p&gt;Yes, that is what I meant although I said it poorly. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was thinking of critical sections used to protect some type of global resource. &amp;nbsp;In this case, there is still only one global resource to protect regardless of process, so the fact that each process has it's own critical section object means that the synchronization mechanism would fail. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;- Dean&lt;/p&gt;
</description></item><item><title>re: Critical Section vs. Mutex</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx#2014056</link><pubDate>Mon, 02 Apr 2007 23:13:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2014056</guid><dc:creator>ce_base</dc:creator><description>&lt;p&gt;Dean,&lt;/p&gt;
&lt;p&gt;When you say &amp;quot;global resource&amp;quot;, if you are referring to system wide data (process agnostic data), then yes critical sections is not the right choice in that case. One could use named mutex in this case to protect access to the shared data or other system wide synchronization mechanisms.&lt;/p&gt;
&lt;p&gt;-Upender&lt;/p&gt;
</description></item><item><title>re: Critical Section vs. Mutex</title><link>http://blogs.msdn.com/ce_base/archive/2007/03/26/critical-section-vs-mutex.aspx#2018524</link><pubDate>Tue, 03 Apr 2007 17:57:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2018524</guid><dc:creator>Dean Ramsier</dc:creator><description>&lt;p&gt;Yes, that's what I meant. &amp;nbsp;Bad choice of words again, sorry! I'm thinking of things like cpu registers etc.&lt;/p&gt;
&lt;p&gt;- Dean&lt;/p&gt;
</description></item></channel></rss>