• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Programming problems in multi-core

itzitzu

n00b
Joined
Oct 21, 2008
Messages
8
Hi!

I’d like to know if it’s possible forcing a process to be executed in the core I choose. I’ll explain it better: I’m going to have two programs in a dual core and I’d like to send some processes to a core and some other to the other one. I know this can be done with the task manager and in a more durable way with programs like PrioAff or Set Affinity II, but my intention is doing it from the code of the program that I’ll make in C. That is, when I create the processes tell them too in which core they’ll be executed.
I hope someone knows anything about this topic and can help me in it.

Thanks in advanced.

P.S. Sorry for my English and I hope someone can understand me.
 
If you're using threads (not sure if it works for processes), you can try the following:

http://msdn.microsoft.com/en-us/library/ms686253(VS.85).aspx

There is SetThreadAffinityMask() and SetThreadIdealProcessor() for the C++ Win32 API. I have a hard time understanding why you'd want to do this though, given that the operating system can adequately schedule your threads and processes so that you're effectively using your hardware.
 
You can call SetThreadAffinityMask() with a mask indicating the processor(s) where you want to lock the thread. You can do it thread-by-thread, or you can do it for a whole process with [http://msdn.microsoft.com/en-us/library/ms686247.aspx]SetProcessAffinityMask()[/URL]. SetThreadIdealProcessor() gives the OS a hint about which processor a thread should be scheduled on, but the OS is free to break that--it's just a recommendation.

Cyrillix is right to ask why you want to do this, though. It's almost never a good idea.
 
I don't think this is really related but I thought I'd give my own personal example of forcing programs to run on a certain core. I know that when I play Counter Strike: Source, there is a very subtle difference (but definitely noticeable if you're a long time player of the game) in the way the guns fire when I let hl2.exe run on both cores of my Opteron 165 as opposed to just one. At first I thought it was just one of those timer issues so I installed various updates as outlined by http://www.hardforum.com/showthread.php?t=983781 :

Fix #1 - The AMD Dual Core Optimizer
Fix #2 - The AMD Driver ( /usepmtimer switch)
Fix #3 - The Microsoft Hotfix

But none of it fixed the problem. I should note that the problem isn't exactly the same as described in the intro of that thread. My framerate and overall smoothness of play is the same regardless of affinity settings. It is very hard for people to really tell the difference, but if you've played the game as long as I have, you know EXACTLY how the guns should fire and ever since I got this CPU I've had this issue of guns firing slightly differently. The only fix that I'm aware of to this day is to set hl2.exe to run on only one core.

Otherwise, my system runs all other applications just fine.
 
Thank for all your answers, now I'll have to read a lot about it and learn how to use this functions.
I've seen too there is a library called TPL that can be used for these things too. Does anyone know something about it? If it's easier or more difficult..
 
The Parallel FX Library, you mean? I don't think it's any easier; it's not supported fully yet, it's still being developed, and you'd have to switch to managed code. Which specific difficulties are you trying to avoid?
 
Back
Top