Help me with my concurrency experiments
Correct me if I'm wrong. Based on my understanding, a CPU with 1 core running 1 thread has the same computing power as another CPU with 1 core running 2 threads. The latter will handle 2 tasks but each task will roughly have half of the computing power. Is there anything in C# I can do to simulate this? Perhaps a function that exits after a certain amount of CPU cycles.
3 Replies
Probably the best way to do that would be to set affinity to a single processor. I think you may be able to do that at the process level. Currently you can't at the managed thread level, see
https://github.com/dotnet/runtime/issues/21363
GitHub
Support controlling thread affinity · Issue #21363 · dotnet/runtime
Purpose Allow control of thread affinity. Proposed API class Thread { ProcessorSet Affinity { get; set; } } The ProcessorSet represents a a set of logical processors. The underlying APIs for Window...
You might ask in the #advanced channel, some of the folks who hang out there might have some ideas
thanks