I've been floating around the web looking for a way to add a cap to my Cpp program's processor use, and so far I've only come across a few painful looking Cpp-to-assembly tutorials and a bindprocessor function in an IBM API. I was wondering if any of you wizards knew how to cap or limit processor use in a C or Cpp program.
I'm already using: SetPriorityClass(theApp, REALTIME_PRIORITY_CLASS); to try and boost the importance of my program during load-time, but I don't see this change reflected in the task manager (which still says my program's priority is 'Normal') Is there some other method that I can use to force M$ windows to listen to my priority designations? Or is she going to do her own thing despite my best efforts?

Additionally, I was wondering if there's a MFC or other option to limit a thread or a program to a single core on a multi-core processor?

(If I can do either of these things, I can finish my project.)

Any help would be well welcome.

> method that I can use to force M$ windows to listen to my priority designations?

run under an account with elevated privileges.

on a normal system, only the memory manager worker threads (balance set manager, modified page writer and mapped page writer) run under real-time priority.

by default, only administrative accounts have the necessary privilege
( "SeIncreaseBasePriorityPrivilege" ) required to set real-time priorities.


> option to limit a thread or a program to a single core SetProcessAffinityMask http://msdn.microsoft.com/en-us/library/ms686223(VS.85).aspx SetThreadAffinityMask http://msdn.microsoft.com/en-us/library/ms686247(VS.85).aspx

ah! an affinity mask! this may be just the thing! I'll check this out just after I finish typing my report for stage 1 of the project. Thank you so much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.