views:

134

answers:

2

I have an application that's having some trouble handling multi-processor systems. It's not an app that I have a particular affection for modifying and would like to avoid it if possible. However, I'm not above modifying the code if I have to. The application is written in VBA (and hence my inclination to avoid touching it).

We've noticed that the application seems to run pretty smoothly if we set the processor affinity to a single processor using task manager, only manifesting instability when processor affinity isn't set.

I know that I can specify the processor affinity of a task using .NET and as such, there lies a possibility of me writing a shell application that could be used to run legacy applications with a specified processor affinity, does anyone have any experience with this and can throw out some ideas as to headaches I'm likely to run into with this approach?

The other question is: Is it in fact possible to modify the core VBA product to handle its own processor affinity? I've never had to handle this with any of my applications natively so this (at this point in time) is completely outside my realm of expertise.

Thanks in advance

+2  A: 

You could use Sysinternal's PsExec to start your application with a certain processor affinity, e.g. to bind Access to CPU 1 call

psexec.exe -a 1 "%ProgramFiles%\Microsoft Office\Office12\access.exe"

To answer your second question: As you tagged the question with access-vba I assume that your VBA code is an Access solution. Your VBA code will then be executed in process, i.e. you will have to modify the processor affinity of the access.exe process. It is not possible to modify the affinity of the VBA engine separately.

However, before you specify a processor affinity make sure that you are fully aware of the consequences. Fiddling around with this setting can have undesired effects. For a good example read Raymond Chen's post:

Psychic debugging: Why your expensive four-processor machine is ignoring three of its processors

0xA3
Our I.T. manager found this hack to make an app that doesn't handle multi-core/multi-processor environment well. I.T. is testing if modifying processor affinity will stabilize the app. If it is, then it'll be an I.T. initiative. I was asked to provide input from a development standpoint.
BenAlabaster
+2  A: 

One way you can do this is with the Windows Application Compatibility Toolkit.

You give it a way to identify your application (e.g. by .exe location), and then it allows you to specify a number of tweaks. Processor affinity is one of them. It creates a database that holds all your tweaks.

It's per-machine, so it's not a good solution for a widely-distributed application, but if this application only has to run on one machine, it'll save you having to change the code.

Kyralessa
Also, be aware that by default version number is one of the items it selects to identify your application. If you regularly change version numbers on updates, you may want to uncheck that as a criterion or your tweaks will stop working with your next upgrade.
Kyralessa