<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
SignalObjectAndWait is widely mentioned as important to implementing condition variables on Win32, however it is documented as not being atomic.<BR>
Search the web:<BR>
<A href="http://msdn.microsoft.com/en-us/library/ms686293(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ms686293(VS.85).aspx</A><BR>
 <BR>
"Note that the "signal" and "wait" are not guaranteed to be performed as an atomic operation. Threads executing on other processors can observe the signaled state of the first object before the thread calling <STRONG>SignalObjectAndWait</STRONG> begins its wait on the second object."<BR>
 <BR>
So it isn't useful, right?<BR>
 <BR>
Thanks,<BR>
 - Jay<BR><BR> <BR>
<HR id=stopSpelling>
From: hosking@cs.purdue.edu<BR>To: m3devel@elegosoft.com<BR>Date: Tue, 29 Sep 2009 13:54:48 -0400<BR>Subject: [M3devel] Win32 threads<BR><BR>
<DIV>I believe that the hangs we are seeing are because of the race present in AlertWait, which permit a thread to miss seeing an alert before waiting on the condition.  We want the thread only to wait if there has been no alert.  Unfortunately, the alert is only protected by the global mutex, which must be release before waiting.  Currently, we release the mutex, then wait, with the resulting race.  This requires a more complicated handshake than currently implemented.  Perhaps using SignalObjectAndWait instead as well as a Win32 mutex on each thread.  Similarly to ThreadPThread.m3.</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="WORD-WRAP: break-word"><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="WORD-WRAP: break-word"><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV><FONT class=ecxApple-style-span color=#0000ff><FONT class=ecxApple-style-span face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span>Antony Hosking</SPAN></SPAN></FONT></FONT><FONT class=ecxApple-style-span face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN class=ecxApple-converted-space> </SPAN>|<SPAN class=ecxApple-converted-space> </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span>Associate Professor</SPAN></SPAN><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span> | Computer Science | Purdue University</SPAN></SPAN></FONT></DIV>
<DIV><FONT class=ecxApple-style-span face=GillSans-Light><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span>305 N. University Street | West Lafayette | IN 47907 | USA</SPAN></FONT></DIV>
<DIV><FONT class=ecxApple-style-span color=#0000ff face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span>Office</SPAN></SPAN></FONT><FONT class=ecxApple-style-span face=GillSans-Light><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span> +1 765 494 6001 |<SPAN class=ecxApple-converted-space> </SPAN></SPAN></SPAN></FONT><FONT class=ecxApple-style-span color=#0000ff face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span>Mobile</SPAN></SPAN></FONT><FONT class=ecxApple-style-span face=GillSans-Light><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span><SPAN class=ecxApple-converted-space> </SPAN>+1 765 427 5484</SPAN></SPAN></FONT></DIV>
<DIV><FONT class=ecxApple-style-span face=GillSans-Light><BR class=ecxkhtml-block-placeholder></FONT></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN><BR class=ecxApple-interchange-newline></SPAN></DIV></SPAN></DIV></SPAN><BR class=ecxApple-interchange-newline></DIV><BR>                                       </body>
</html>