I have been reading lately about system architecture
and the topic of multi-threading
has not been covered in detail with latest improvements in technology. I did my part of search, but could not find answers for the following:
The questions have are
1) Is multi-threading
dependent on the system architecuture (CPU)
. do all CPU (single core)
support multi-threading
? If it does not, what happens to multi-threaded
applications when run on those machines
It is cited here that
Intel CPUs support multithreading, but only two threads per CPU.
AMD CPUs do not support multithreading and AMD often sites Microsoft's
recommendations to turn off Hyperthreading on Intel CPUs when running applications
like peoplesoft and Exchange.
2) so what does it mean it say only two threads per CPU
here. At any given time, CPU (single core)
can process only thread
. and the other thread
is waiting to be processed correct?
3) how is it different from an application that spawns, say, 10 threads
and waiting for them to be executed. If the CPU at the most can tackle only two threads
, shouldn't programmer keep that fact in consideration when writing multi-threaded applications
.
Even with multi-core processors (say quad-core)
at the most 8 threads can be queued
, but only 4 threads
can be processed at the same time.
P.S: I have a read a little about hyper-threading
but I am not sure if that is relevant here and if
all processors support hyper-threading
1) It depends on the operating system more than anything. Even for single core architectures, multi-threading can be supported, but the threads are not executing in parallel - The OS will context-switch between them.
2) Intel usually supports two-way hardware threading ( also called simultaneous multi-threading), where each thread is allocated a pipeline. So if you have a process with two threads they can both execute on the same core simultaneously.
3) See 1. Basically the operating system is going to allocate as many threads as it can to hardware before it plans to context-switch between the threads it couldn't allocate. This process is dependent on the OS's scheduler, and you can read about the Linux one to get a good idea of what's going on.
Edit: Hypethreading is basically the hardware threading feature I mentioned.