C
C#3mo ago
cheeze2000

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
mtreit
mtreit3mo ago
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...
mtreit
mtreit3mo ago
You might ask in the #advanced channel, some of the folks who hang out there might have some ideas
cheeze2000
cheeze20003mo ago
thanks