Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing an app to run single core only?

I have this strange issue with some third party DLL's. The third party provider references some open source DLL's that have a memory exception whenever I try to use a certain method. This issue does not appear when the app is run on a single core machine, but obviously we cannot assume a user will have that.

Is there a way to force an app, or even better yet a referenced DLL to run on a single core? Any other way to possibly fix this? Getting the third party to rebuild the OS dll's is apparently out of the question (its a bit of a sore spot with me currently :) ) so I have to handle it myself or just forget about providing this functionality.

By the way, the error message being thrown from the OS DLL's is "Attempting to access corrupt or protected memory".

like image 640
Kevin Avatar asked Sep 21 '25 02:09

Kevin


1 Answers

What you want to do is achieved by using Process.ProcessorAffinity. Note that this will make your entire application run single-core.

Edit: your problem may be a result of the DLL expecting to have single-processor affinity, but it can also be a threading issue (e.g. race condition) that is very unlikely to happen when you only have a single core. If the last one is true, you can't really do anything except cross your fingers and pray (and maybe consider dropping the functionality to keep your application stable).

like image 154
Jon Avatar answered Sep 22 '25 16:09

Jon