Open ShigiDono opened 9 years ago
#include <windows.h>
DWORD WINAPI ThreadProc(CONST LPVOID lpParam) {
while (true);
ExitThread(0);
}
INT main() {
TCHAR szMessage[256];
DWORD dwTemp, i;
HANDLE hThreads[2];
for(i = 0; i < 2; i++) {
hThreads[i] = CreateThread(NULL, 0, &ThreadProc, NULL, 0, NULL);
}
WaitForMultipleObjects(2, hThreads, TRUE, INFINITE);
for(i = 0; i < 2; i++) {
CloseHandle(hThreads[i]);
}
ExitProcess(0);
}
Producing ~ >150 % on 2-core machine
Checked SetProcessAffinityMask(process_info.hProcess, 1);
. Gives ~100%
Check run.exe with same program/approach. This is the output of run.exe on this specific program. Running "another.exe", press ESC to terminate...
Program successfully terminated
exit code: 1
time consumed: 14.96 sec
time passed: 8.66 sec
peak memory: 5038080 bytes
Multithread program with
while (true);
in each thread (w/o optimization) producing >100% on multicore machine.