Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello
i want to set a thread or task to one core's of cpu and manage it in c#?
of corse whitout Process.GetCurrentProcess().ProcessorAffinity
please F1F1F1F1F1F1F1F1 !!!!!!!!!!!
thnx
Posted

Without setting processor affinity, you can't.

It's also a bad idea unless you have VERY SPECIFIC reasons for doing so and know the pitsfalls.

One such pitfall is that you limit your code to running on single core even if the core is also busy doing other things and other cores are idle. Your code gets to wait, even though there may be an available core.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Jun-11 13:16pm    
Formally speaking, you're not 100% right, because the is also thread affinity. (Nevertheless, my 5.)

Please see my answer.
--SA
Dave Kreskowiak 3-Jun-11 13:40pm    
I know. The same rules and pitfalls apply in either case.
Sergey Alexandrovich Kryukov 3-Jun-11 20:17pm    
Absolutely.
--SA
Except for process affinity, there is also a thread affinity.

Please see my past answer: How to program multicore[^].

Again, in agreement with Dave, don't interfere in thread/process affinity unless you know exactly what are you doing!

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900