Search code examples
.netmultithreadingmulticore

.NET movement of threads between cores


Follow up question from Multi-core usage, threads, thread-pools.

Are threads moved from one core to another during their lifetime?

Of course. Imagine you have three threads running on a dualcore system. Show me a fair schedule that doesn't involve regularly moving threads between cores.

This is my first time on this site, so I didn't have enough rep to comment I guess. I decided to just make a new question referencing the one I wanted to comment on.

What is the process of selecting a core to move a thread to. Is it like the scheduler has a list of threads that need processing time and as one finishes it puts another one in?

Also I was wondering if there is a reference for the statement that threads are moved between cores at all. Or is it just considered "common knowlege"?

Thanks!


Solution

  • It's not like the thread is living on a particular core and that it is a process of moving it to another.

    The operating system simply has a list of threads (and/or processes) that are ready to execute and will dispatch them on whatever core/cpu that happens to be available.

    That said, any smart scheduler will try to schedule the thread on the same core as much as possible - simply to increase performance (data is more likely to be in that core's cache etc.)