I have some questions about multi-threaded programming and multi-core usage.
In particular I'm wondering how the operating system and/or framework (this is .NET) deals with cores that are heavily used.
Here's my questions regarding threads:
- When a new thread is spawned, what is the algorithm for assigning the thread to a particular core?
- Round-robin type of algorithm
- Random
- The currently least used core
- If not the currently least used core, would this type of code that determined this dwarf the typical use of a thread and thus just make matters worse?
- Are threads moved from one core to another during their lifetime? If so, is this to handle cores that for some reason gets "overused" and thus the operating system try to shuffle threads over to less used cores to help the system? If not, again, why not?
My final question, which is basically a reuse of the above, is about the .NET ThreadPool class, which handles things like .BeginInvoke and such. Does this class do any of this stuff? If not, why not, or should it?
Is there any way to tweak this handling, sort of hint at the operating system that this particular thread, please pay a bit more attention to it when you assign it a core, since I know it will use a lot of cpu. Would that make sense? Or would "a lot of cpu" just be relative and thus not really good enough?