[M3devel] Win32 SuspendThread?

Jay jay.krell at cornell.edu
Mon Jan 20 01:06:27 CET 2014


Cooperative suspend will also fix this signal allocation vs. valgrind problem. Can also likely pick a different one...

 - Jay

On Jan 19, 2014, at 12:05 PM, <mika at async.caltech.edu> wrote:

> "less worried" = "I think it works"?
> 
> I think the only threading that works in CM3 is user threading...
> 
> I tried to run CM3-compiled binaries through "valgrind" but got an
> error that CM3 is using the same signal that valgrind does internally
> (on AMD64_LINUX at least).  I think this is easy to change in m3core
> (yes?) but haven't gotten around to it...
> 
> valgrind has a threading checker called "helgrind"...
> 
>     Mika
> 
> Jay writes:
>> 
>> --Apple-Mail-79A8190D-B4F0-41F1-AA37-366ED17CF55A
>> Content-Type: text/plain;
>>    charset=utf-8
>> Content-Transfer-Encoding: quoted-printable
>> 
>> For native I'm less worried now. For wow64 I'm still worried & hope to follo=
>> w up further.
>> 
>> - Jay
>> 
>> On Jan 17, 2014, at 11:11 PM, "Coleburn, Randy" <rcolebur at SCIRES.COM> wrote:=
>> 
>> 
>>> Jay:
>>> =20
>>> I=E2=80=99m very concerned about the threading not working properly on bot=
>> h 32-bit and 64-bit Windows.
>>> =20
>>> The Thread Test program crashes for me on both platforms.
>>> =20
>>> I haven=E2=80=99t tried your new test program yet.
>>> =20
>>> --Randy
>>> =20
>>> From: jayk123 at hotmail.com [mailto:jayk123 at hotmail.com] On Behalf Of Jay K
>>> Sent: Saturday, January 18, 2014 1:23 AM
>>> To: m3devel
>>> Subject: EXT:[M3devel] Win32 SuspendThread?
>>> =20
>>> This program also doesn't behave as expected, native, nothing to do with w=
>> ow64.=20
>>> Anyone else please confirm:=20
>>>   1) my expectations -- it should never print anything
>>>   2) their importance  -- garbage collector depends on it =20
>>>   3) their not being met -- stuff gets printed=20
>>> This is in the CVS repository, scratch/wow64stack/sync2.cpp=20
>>> I am following up further.=20
>>> Maybe we should get cooperative suspend really going?=20
>>> Thank you.
>>> - Jay=20
>>> =20
>>> #include <stdio.h>
>>> #include <windows.h>
>>> volatile long value;
>>> unsigned long __stdcall Thread(PVOID parameter)
>>> {
>>>  while (1)
>>>   InterlockedIncrement(&value);
>>>  return 0;
>>> }
>>> int __cdecl main()
>>> {
>>>  HANDLE thread =3D CreateThread(0, 0, Thread, 0, 0, 0);
>>>  UINT i =3D 0;
>>>  while (1)
>>>  {
>>>    i +=3D 1;
>>>    if (SuspendThread(thread) =3D=3D (DWORD)-1)
>>>    {
>>>      printf("suspend failed %X\n", GetLastError());
>>>      Sleep(1);
>>>      continue;
>>>    }
>>>    volatile long a =3D value;=20
>>>    volatile long b =3D value;
>>>    if (a !=3D b)
>>>    {
>>>     printf("%d %d %d %d\n", i, a, b, b - a);
>>>    }
>>>    ResumeThread(thread);
>>>  }
>>> }
>> 
>> --Apple-Mail-79A8190D-B4F0-41F1-AA37-366ED17CF55A
>> Content-Type: text/html;
>>    charset=utf-8
>> Content-Transfer-Encoding: quoted-printable
>> 
>> <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
>> utf-8"></head><body dir=3D"auto"><div>For native I'm less worried now. For w=
>> ow64 I'm still worried & hope to follow up further.<br><br> - Jay</=
>> div><div><br>On Jan 17, 2014, at 11:11 PM, "Coleburn, Randy" <<a href=3D"=
>> mailto:rcolebur at SCIRES.COM">rcolebur at SCIRES.COM</a>> wrote:<br><br></div>=
>> <blockquote type=3D"cite"><div>
>> 
>> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii">=
>> 
>> <meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
>> <style><!--
>> /* Font Definitions */
>> @font-face
>>    {font-family:Calibri;
>>    panose-1:2 15 5 2 2 2 4 3 2 4;}
>> @font-face
>>    {font-family:Tahoma;
>>    panose-1:2 11 6 4 3 5 4 4 2 4;}
>> /* Style Definitions */
>> p.MsoNormal, li.MsoNormal, div.MsoNormal
>>    {margin:0in;
>>    margin-bottom:.0001pt;
>>    font-size:12.0pt;
>>    font-family:"Times New Roman","serif";}
>> a:link, span.MsoHyperlink
>>    {mso-style-priority:99;
>>    color:blue;
>>    text-decoration:underline;}
>> a:visited, span.MsoHyperlinkFollowed
>>    {mso-style-priority:99;
>>    color:purple;
>>    text-decoration:underline;}
>> p
>>    {mso-style-priority:99;
>>    mso-margin-top-alt:auto;
>>    margin-right:0in;
>>    mso-margin-bottom-alt:auto;
>>    margin-left:0in;
>>    font-size:12.0pt;
>>    font-family:"Times New Roman","serif";}
>> p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
>>    {mso-style-priority:99;
>>    mso-style-link:"Balloon Text Char";
>>    margin:0in;
>>    margin-bottom:.0001pt;
>>    font-size:8.0pt;
>>    font-family:"Tahoma","sans-serif";}
>> span.EmailStyle18
>>    {mso-style-type:personal-reply;
>>    font-family:"Calibri","sans-serif";
>>    color:#1F497D;}
>> span.BalloonTextChar
>>    {mso-style-name:"Balloon Text Char";
>>    mso-style-priority:99;
>>    mso-style-link:"Balloon Text";
>>    font-family:"Tahoma","sans-serif";}
>> .MsoChpDefault
>>    {mso-style-type:export-only;
>>    font-size:10.0pt;}
>> @page WordSection1
>>    {size:8.5in 11.0in;
>>    margin:1.0in 1.0in 1.0in 1.0in;}
>> div.WordSection1
>>    {page:WordSection1;}
>> --></style><!--[if gte mso 9]><xml>
>> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
>> </xml><![endif]--><!--[if gte mso 9]><xml>
>> <o:shapelayout v:ext=3D"edit">
>> <o:idmap v:ext=3D"edit" data=3D"1" />
>> </o:shapelayout></xml><![endif]-->
>> 
>> 
>> <div class=3D"WordSection1">
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D">Jay:<o:p></o:p></span></p>
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p=
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D">I=E2=80=99m very concerned a=
>> bout the threading not working properly on both 32-bit and 64-bit Windows.<o=
>> :p></o:p></span></p>
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p=
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D">The Thread Test program cra=
>> shes for me on both platforms.<o:p></o:p></span></p>
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p=
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D">I haven=E2=80=99t tried you=
>> r new test program yet.<o:p></o:p></span></p>
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p=
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D">--Randy<o:p></o:p></span></=
>> p>
>> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Cal=
>> ibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p=
>> <div>
>> <div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0=
>> in 0in">
>> <p class=3D"MsoNormal" style=3D"margin-left:.5in"><b><span style=3D"font-siz=
>> e:10.0pt;font-family:"Tahoma","sans-serif"">From:</span>=
>> </b><span style=3D"font-size:10.0pt;font-family:"Tahoma","san=
>> s-serif""> <a href=3D"mailto:jayk123 at hotmail.com">jayk123 at hotmail.com</=
>> a> [<a href=3D"mailto:jayk123 at hotmail.com">mailto:jayk123 at hotmail.com</a>]
>> <b>On Behalf Of </b>Jay K<br>
>> <b>Sent:</b> Saturday, January 18, 2014 1:23 AM<br>
>> <b>To:</b> m3devel<br>
>> <b>Subject:</b> EXT:[M3devel] Win32 SuspendThread?<o:p></o:p></span></p>
>> </div>
>> </div>
>> <p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
>> <div>
>> <p class=3D"MsoNormal" style=3D"mso-margin-top-alt:0in;margin-right:0in;marg=
>> in-bottom:12.0pt;margin-left:.5in">
>> <span style=3D"font-family:"Calibri","sans-serif"">&nbsp=
>> ;This program also doesn't behave as expected, native, nothing to do with wo=
>> w64.
>> <br>
>>  Anyone else please confirm: <br>
>>    1) my expectations -- it should never print anything<br>
>>    2) their importance  -- garbage collector depends on it&nb=
>> sp; <br>
>>    3) their not being met -- stuff gets printed <br>
>>  This is in the CVS repository, scratch/wow64stack/sync2.cpp <br>
>>  I am following up further. <br>
>>  Maybe we should get cooperative suspend really going? <br>
>> Thank you.<br>
>>  - Jay <br>
>>  <br>
>> #include <stdio.h><br>
>> #include <windows.h><br>
>> volatile long value;<br>
>> unsigned long __stdcall Thread(PVOID parameter)<br>
>> {<br>
>>   while (1)<br>
>>    InterlockedIncrement(&value);<br>
>>   return 0;<br>
>> }<br>
>> int __cdecl main()<br>
>> {<br>
>>   HANDLE thread =3D CreateThread(0, 0, Thread, 0, 0, 0);<br>
>>   UINT i =3D 0;<br>
>>   while (1)<br>
>>   {<br>
>>     i +=3D 1;<br>
>>     if (SuspendThread(thread) =3D=3D (DWORD)-1)<br>
>>     {<br>
>>       printf("suspend failed %X\n", GetLastError())=
>> ;<br>
>>       Sleep(1);<br>
>>       continue;<br>
>>     }<br>
>>     volatile long a =3D value; <br>
>>     volatile long b =3D value;<br>
>>     if (a !=3D b)<br>
>>     {<br>
>>      printf("%d %d %d %d\n", i, a, b, b - a);<br>
>>     }<br>
>>     ResumeThread(thread);<br>
>>   }<br>
>> }<o:p></o:p></span></p>
>> </div>
>> </div>
>> 
>> 
>> </div></blockquote></body></html>=
>> 
>> --Apple-Mail-79A8190D-B4F0-41F1-AA37-366ED17CF55A--



More information about the M3devel mailing list