Threads vs Cores

前端 未结 4 1404
长发绾君心
长发绾君心 2020-12-30 02:43

Say if I have a processor like this which says # cores = 4, # threads = 4 and without Hyper-threading support.

Does that mean I can run 4 simultaneous program/proces

4条回答
  •  一个人的身影
    2020-12-30 03:20

    A thread differs from a process. A process can have many threads. A thread is a sequence of commands that have a certain order. A logical core can execute on sequence of commands. The operating system distributes all the threads to all the logical cores available, and if there are more threads than cores, threads are processed in a fast cue, and the core switches from one to another very fast.

    It will look like all the threads run simultaneously, when actually the OS distributes CPU time among them.

    Having multiple cores gives the advantage that less concurrent threads will be placed on one single core, less switching between threads = greater speed.

    Hyper-threading creates 2 logical cores on 1 physical core, and makes switching between threads much faster.

提交回复
热议问题