<pre><font size="2">To: </font><a href="mailto:ace-bugs@cs.wustl.edu" target="_blank"><font size="2">ace-bugs@cs.wustl.edu</font></a></pre><pre><font size="2">Subject: ACE_RW_Process_Mutex in single writer and multiple readers</font></pre>
<pre><font size="2">ACE VERSION: 5.5.8</font></pre><pre><font size="2">HOST MACHINE and OPERATING SYSTEM:</font></pre><pre><font size="2"> </font></pre><pre><font size="2">Windows XP Professional and Enterprise Linux 5.0</font></pre>
<pre><font size="2">Version 2002</font></pre><pre><font size="2">TARGET MACHINE and OPERATING SYSTEM, if different from HOST:NO</font></pre><pre><font size="2">COMPILER NAME AND VERSION (AND PATCHLEVEL):</font></pre><pre>
<font size="2">Visual studio 2005</font></pre>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">THE $ACE_ROOT/ace/config.h FILE </span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">#include "ace/config-win32.h"<span style="mso-spacerun: yes"> </span>for windows</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">#include "ace/config-linux.h"<span style="mso-spacerun: yes"> </span>for linux</span></p><pre>
<font size="2">DOES THE PROBLEM AFFECT:</font></pre><pre><font size="2"> COMPILATION? NO</font></pre><pre><font size="2"> LINKING? NO</font></pre><pre><font size="2"> EXECUTION? YES</font></pre>
<pre><font size="2"> OTHER </font></pre><pre><font size="2"> SYNOPSIS:</font></pre>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Use of ACE_RW_Process_Mutex.I developed a very simple program which needs to be extended for Multiple readers and single writer ( shared memory concept using a Hash Map with allocator)</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Even a single Reader and single writer are not getting syncronized.Please provide with a sample program of ACE_RW_Process_Mutex.</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> </span></p><pre><font size="2">DESCRIPTION:</font></pre><pre><font size="2">After having a look into ACE_ROOT/examples/Threads ,I implemented the following code using ACE_RW_Process_Mutex. and run in both Windows and linux5.0. But in both the cases the synchronization is not happening .</font></pre>
<pre><font size="2"> </font></pre><pre><font size="2">The Code is written as below</font></pre><pre><span style="FONT-FAMILY: Arial"><font size="2"> </font></span></pre><pre><font size="2"> </font></pre>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">int ACE_TMAIN (int argc, ACE_TCHAR *argv[])</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">{</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> ACE_RW_Process_Mutex m_RWMutex(ACE_TEXT("MyMutex"));</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> if (agrc == 1)</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> while (1)</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> if (m_RWMutex.acquire_write() == 0)</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> ACE_OS::printf("Writer acquired...\n");</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> ACE_OS::sleep(2);</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> ACE_OS::printf("Writer releasing...\n");</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> m_RWMutex.release();</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> else</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> while (1)</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> if (m_RWMutex.acquire_read() == 0)</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> ACE_OS::printf("Writer acquired...\n");</span></p>