-
Multiple Processors
Guys,
Since I have moved to C# I am quickly writing bigger and better apps than I ever could using VB. One of things I am experimenting with now is having multiple threads and processes.
I know Exchange and SQL are all multi-proc aware. If your server is running slow, you can through another processor at it and it will take advantage of it without doing anything.
My question is, and I apologize if this is in the wrong forum, I didn't feel the general computing was the right place, how do you write the code to take advantage of a system with multiple. When you spawn a new process, does Windows handle where the process gets run? Is there a way to direct it to a certain process.
The main reason I ask, I am writing an app to run on one of our servers that has 4 processors. I dont want to peg one of them out.
Thanks,
Jerel
-
Yes, Windows generally takes care of this. You can control it somewhat by setting thread priorities and what not, but for the most part, Windows will handle it for you. Definately thread out long running processes. It just makes sense.
-
You can also call into the API (doesn't know if it's available in the .Net Framework) to set a preferred CPU for a thread. I can't see where this would be very useful though.
Developing for multi-CPU systems means making all your code extra thread-safe. It also means that you think hard about what code could run concurrently with other code and split those into separate threads so that they actually CAN run concurrently.
-
The .Net framework has some very sexy threading capability that will let you identify and eliminate potentially racing threads, dormant threads etc... Funky.
Managed C++, yeah!