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 core.
Edit:
If my application runs many threads, all these threads will run on one process.
Without parallel programming..
Is the process able to devide and run on many core ?
Does my application get benifit of multi-core processing ?
Instead of giving a large workload to a single core, threaded programs split the work into multiple software threads. These threads are processed in parallel by different CPU cores to save time.
A thread's affinity dictates which CPU cores the OS can schedule the thread to execute on. By default, a thread can be scheduled to execute on any CPU core. When a thread is switched out, it could be scheduled to run on a different CPU core when it's switched back in (that is, when it floats to another core).
Because a single kernel thread can operate only on a single CPU, the many-to-one model does not allow individual processes to be split across multiple CPUs.
Can two threads be assigned to different processors and execute at the same time? Yes. A couple of threads may be sharing a processor core, with one running while the other waits. Modern CPUs often have hyper-threading technology to make this switching back and forth quite cheap (little overhead, fast performance).
(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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With