Search code examples
multithreadingcputhreadpool

What is the difference between the thread in CPU (hardware) and those in thread pool


People always call CPU has 4 cores & 8 threads or 2 cores & 2 threads, etc.

But in the thread pool, there are quite a lot of tiny threads generated, are these related to the hardware threads?

I am thinking if the CPU threads are actually processes.

Also, I think the actual thread is just a block of code that runs while loop and execute available task otherwise sleep, is this statement correct?


Solution

  • On the hardware side the CPU has cores, cores have 1-8 schedulable threads, new Power-CPUs have up to 8 threads, Knightbridge(?) has 4, most other desktop CPU's have 2, older and/or smaller CPU's got 1.

    On the software side a program can have multiple processes (different virtual memory mapping), a process can multiple software threads (sharing the processes memory map), a software thread is the scheduling partner for the hardware thread.

    Then you again can have a logical thread in software, often called a fiber, which is a user software scheduled mini thread run by a software thread.