Threads & Processes Vs MultiThreading & Multi-Core/MultiProcessor : How they are mapped? Threads & Processes Vs MultiThreading & Multi-Core/MultiProcessor : How they are mapped? multithreading multithreading

Threads & Processes Vs MultiThreading & Multi-Core/MultiProcessor : How they are mapped?


First, try to understand the concept of 'process' and 'thread'. A thread is a basic unit for execution: a thread is scheduled by operating system and executed by CPU. A process is a sort of container that holds multiple threads.

  1. Yes, either multi-processing or multi-threading is for parallel processing. More precisely, to exploit thread-level parallelism.

  2. Okay, multi-threading could mean hardware multi-threading (one example is HyperThreading). But, I assume that you just say multithreading in software. In this sense, CPU should support context switching.

  3. Context switching is needed to implement multi-tasking even in a physically single core by time division.

  4. Say there are two physical cores and four very busy threads. In this case, two threads are just waiting until they will get the chance to use CPU. Read some articles related to preemptive OS scheduling.

  5. The number of thread that can physically run in concurrent is just identical to # of logical processors. You are asking a general thread scheduling problem in OS literature such as round-robin..

I strongly suggest you to study basics of operating system first. Then move on multithreading issues. It seems like you're still unclear for the key concepts such as context switching and scheduling. It will take a couple of month, but if you really want to be an expert in computer software, then you should know such very basic concepts. Please take whatever OS books and lecture slides.


Threads running on the same core are not technically parallel. They only appear to be executed in parallel, as the CPU switches between them very fast (for us, humans). This switch is what is called context switch. Now, threads executing on different cores are executed in parallel. Most modern CPUs have a number of cores, however, most modern OSes (windows, linux and friends) usually execute much larger number of threads, which still causes context switches. Even if no user program is executed, still OS itself performs context switches for maintanance work.
This should answer 1-3.

About 4: basically, every processor can work with threads. it is much more a characteristic of operating system. Thread is basically: memory (optional), stack and registers, once those are replaced you are in another thread.

5: the number of threads is pretty high and is limited by OS. Usually it is higher than regular programmer can successfully handle :)The number of threads is dictated by your program:

is it IO bound?

  • can the task be divided into a number of smaller tasks?
  • how small is the task? the task can be too small to make it worth to spawn threads at all.
  • synchronization: if extensive synhronization is required, the penalty might be too heavy and you should reduce the number of threads.


Multiple threads are separate 'chains' of commands within one process. From CPU point of view threads are more or less like processes. Each thread has its own set of registers and its own stack.

The reason why you can have more threads than CPUs is that most threads don't need CPU all the time. Thread can be waiting for user input, downloading something from the web or writing to disk. While it is doing that, it does not need CPU, so CPU is free to execute other threads.

In your example, each tab of Firefox probably can even have several threads. Or they can share some threads. You need one for downloading, one for rendering, one for message loop (user input), and perhaps one to run Javascript. You cannot easily combine them because while you download you still need to react to user's input. However, download thread is sleeping most of the time, and even when it's downloading it needs CPU only occasionally, and message loop thread only wakes up when you press a button.

If you go to task manager you'll see that despite all these threads your CPU use is still quite low.

Of course if all your threads do some number-crunching tasks, then you shouldn't create too many of them as you get no performance benefit (though there may be architectural benefits!).

However, if they are mainly I/O bound then create as many threads as your architecture dictates. It's hard to give advice without knowing your particular task.