c++ - XP app won't increase cpu utilization -



c++ - XP app won't increase cpu utilization -

i trying prepare problem legacy visual studio win32 un-managed c++ app not keeping input. part of solution, exploring bumping class , thread priorities.

my pc has 4 xeon processors, running 64 bit xp. wrote short win32 test app creates 4 background looping threads, each 1 running on own processor. code samples shown following. problem when bump priorities extreme, cpu utilization still less 1%.

my test app 32 bit, running on wow64. same test app utilizes less 1% cpu utilization on 32 bit xp machine. administrator on both machines. else need work?

dword __stdcall threadproc4 (lpvoid) { setthreadpriority(getcurrentthread(),thread_priority_time_critical); while (true) { (int = 0; < 1000; i++) { int p = i; int reddish = p *5; theclassprior4 = getpriorityclass(theprocesshandle); } sleep(1); } } int apientry _twinmain(...) { ... theprocesshandle = getcurrentprocess(); bool theaffinity = getprocessaffinitymask( theprocesshandle,&theprocessmask,&thesystemmask); setpriorityclass(theprocesshandle,realtime_priority_class); dword threadid4 = 0; handle thread4 = createthread((lpsecurity_attributes)null, 0, (lpthread_start_routine)threadproc4, null, 0, &threadid4); dword_ptr theaff4 = 8; dword_ptr theaf4 = setthreadaffinitymask(thread1,theaff4); setthreadpriority(thread4,thread_priority_time_critical); resumethread(thread4);

well, if want eat cpu time, you'll want remove 'sleep' phone call - 'processing' taking no important amount of time, , it's spending of it's time sleeping.

you'll want @ optimizer doing code. wouldn't totally surprised if removed 'p' , 'red' (and multiply) in loop (because results never used). trying marking 'red' volatile, should forcefulness not remove calculation.

c++

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -