Threads vs Cores

前端 未结 4 1399
长发绾君心
长发绾君心 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:01

    Basically this is up to the OS. A thread is a high-level construct holding a instruction pointer, and where the OS places a threads execution on a suitable logical processor. So with 4 cores you can basically execute 4 instructions in parallell. Where as a thread simply contains information about what instructions to execute and the instructions placement in memory.

    An application normally uses a single process during execution and the OS switches between processes to give all processes "equal" process time. When an application deploys multiple threads the processes allocates more than one slot for execution but shares memory between threads.

    Normally you make a difference between concurrent and parallell execution. Where parallell execution is when you actually physically execute instructions of more than one logical processor and concurrent execution is the the frequent switching of a single logical processor giving the apperence of parallell execution.

提交回复
热议问题