Your application is terminating before your threads are done running. Put a Sleep()
or more appropriately a WaitForMultipleObjects()
call in your main function after starting the threads, like this:
int main(int argc, char **args)
{
DWORD_PTR c = GetNumCPUs();
m_threads = new HANDLE[c];
InitializeCriticalSectionAndSpinCount(&g_crit_sec, 0x80000400);
for(DWORD_PTR i = 0; i < c; i++)
{
DWORD_PTR m_id = 0;
DWORD_PTR m_mask = 1 << i;
m_threads[i] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadMain, (LPVOID)i, NULL, (LPDWORD)&m_id);
SetThreadAffinityMask(m_threads[i], m_mask);
//wprintf(L"Creating Thread %d (0x%08x) Assigning to CPU 0x%08x\r\n", i, (LONG_PTR)m_threads[i], m_mask);
}
// Waits for all started threads to complete:
WaitForMultipleObjects(c, m_threads, TRUE, INFINITE);
return 0;
}