Is is possible to permanently set processor affinity?

swartwe
swartwe used Ask the Experts™
on
I have a dual processor Pentium Pro and I wish to always run a given application on one processor or the other ("hard affinity" in Microsoft terms).  I know how to temporarily set it through the task manager but this application-to-processor association is lost when the application ends.

The primary application I use is Microsoft Excel 95/97.  I am looking for means by which I can "permanently" set this processor affinity (utility, registry tweak, etc.).
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I don't know of a meathod for this. MS is very proud of the fact that most of their apps usually run faster with SMP. Are you saying Excel runs faster with 1 processor?

Author

Commented:
I don't mean to imply that Excel runs faster with one processor.  However, I have an Excel application which often requires hours to run and I want to dedicate it to one processor so that system response will always be good, regardless of what Excel is doing (even though doing so will cause the Excel application take considerably longer to run).  This is why I want to explicitly set the affinity.
Commented:
Create a simple application as follows:

void main(int argc, char ** argv)
{
    // Set desired affinity
    SetProcessorAffinity( ...whatever affinity you'd like...);
    // Launch Excel and let it inherit this affinity
    CreateProcess("C:\Program Files\...\excel.exe");
}

Then compile this and call it "myexcel.exe" or whatever.  When you run it, it will launch excel proper.

Author

Commented:
I cannot find the function "SetProcessAffinity" within the context of VC++ 5.0.  However, I can find "SetProcessAffinityMask".  It that the correct function?

Author

Commented:
Correction to the last comment...It should have read "I cannot find the function "SetProcessorAffinity"...".  

Incidently, I found SetProcessAffinityMask in winbase.h.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial