[M3devel] Win32 SuspendThread?

Jay K jay.krell at cornell.edu
Sat Jan 18 07:22:53 CET 2014


 This program also doesn't behave as expected, native, nothing to do with wow64. 
 Anyone else please confirm: 
   1) my expectations -- it should never print anything
   2) their importance  -- garbage collector depends on it  
   3) their not being met -- stuff gets printed 
 This is in the CVS repository, scratch/wow64stack/sync2.cpp 
 I am following up further. 
 Maybe we should get cooperative suspend really going? 
Thank you.
 - Jay 
 
#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 = CreateThread(0, 0, Thread, 0, 0, 0);
  UINT i = 0;
  while (1)
  {
    i += 1;
    if (SuspendThread(thread) == (DWORD)-1)
    {
      printf("suspend failed %X\n", GetLastError());
      Sleep(1);
      continue;
    }
    volatile long a = value; 
    volatile long b = value;
    if (a != b)
    {
     printf("%d %d %d %d\n", i, a, b, b - a);
    }
    ResumeThread(thread);
  }
}

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20140118/26ed6280/attachment-0001.html>


More information about the M3devel mailing list