Do threads by default run on more than one core?

后端 未结 4 884
醉话见心
醉话见心 2021-02-05 17:55

In multi-core processors, and windows application runs many threads. do the threads by default run on more than one core ? I mean every thread might run on individual c

4条回答
  •  情深已故
    2021-02-05 18:21

    (Your question is fairly unclear. I hope I've answered what you were asking, but if you can clarify the question that would help.)

    It's up to the OS where a thread is scheduled. There are advantages to keeping a thread on the same core if possible, in terms of cache coherency etc — but forcing it to stay on the same core is usually overly restrictive.

    In short: yes, a thread can run on different cores. Not at the same time, of course - it's only one thread of execution — but it could execute on core C0 at time T0, and then on core C1 at time T1.

    EDIT: You talk about an application running many threads, but "without parallel programming" — that's a contradiction in terms. If you're using many threads, you are using parallel programming, and by default those threads can run on multiple cores. If you're only using one thread, then you won't get any benefit from having multiple cores — other than the fact that other processes can use the other cores, of course.

提交回复
热议问题