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

后端 未结 7 2002
灰色年华
灰色年华 2020-12-07 08:49

I was very confused but the following thread cleared my doubts:

Multiprocessing, Multithreading,HyperThreading, Multi-core

But it addresses the queries from

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 09:10

    I think answers so far are pretty much to the point and give you a good basic context. In essence, say you have quad core processor, but each core is capable of executing 2 simultaneous threads.

    Note, that there is only slight (or no) increase of speed if you are running 2 simultaneous threads on 1 core versus you run 1st thread and then 2nd thread vertically. However, each physical core adds speed to your general workflow.

    Now, say you have a process running on your OS that has multiple threads (i.e. needs to run multiple things in "parallel") and has some kind of stack of tasks in a queue (or some other system with priority rules). Then software sends tasks to a queue and your processor attempts to execute them as fast as it can. Now you have 2 cases:

    1. If a software supports multiprocessing, then tasks will be sent to any available processor (that is not doing anything or simply finished doing some other job and job send from your software is 1st in a queue).
    2. If your software does not support multiprocessing, then all of your jobs will be done in a similar manner, but only by one of your cores.

    I suggest reading Wikipedia page on thread. Very first picture there already gives you a nice insight. :)

提交回复
热议问题