0

I have this whining question on my head, which stuck me for days.

Correct me if I'm wrong: My aspect on computer architecture and organisation is that,

  1. In early day computers, there was a single processor on a single chip.

  2. And with evaluation there were multi-chip processors, with each chip having a single processor.

  3. Then in modern days there are multiprocessors. With each processor chip called a socket, this socket contained multiple processors. They are called cores.

    • Core: An individual processing unit on a processor chip. A core may be equivalent in functionality to a CPU on a single - CPU system.

Now I will briefly lay my understanding on Hyper Threading Technology.

  • For each physical core that is actually present in the socket, the operating system addresses two virtual (logical) cores and shares the workload whenever possible.

  • These cores have multiple levels of large memory caches . And the logical processors sharing the execution units of each of core.

Now my question is what is a thread?

As a programmer when I create two threads and I run my program, how does the threads divide in to cores.

I want to know that on which logical processors that these threads run on.

I gave myself an answer for that,

These threads must be run on two separate logical processors that belongs to two physical cores, because if we divide these threads to the two logical processors of one physical core, concurrency is not achieved. As one logical processor is run at a given time in one physical core.

If my answer for my problem is wrong please help me out. I really appreciate it.

  • 1
    See the 2nd suggested duplicate answer. You are at the mercy of the OS scheduler, which will pick which logical cores to run your threads on. As far as I'm aware, schedulers will not dip into hyper-threading until all physical cores are already in use. Even then, there are still advantages to running in hyper-threaded mode. The processor itself can schedule work in very fine grain, sub-architectural levels to offer threads the functional units of the core the other thread is not using. You can lookup Simultaneous Multi-threading (SMT) for information about how this is still useful. – Andy Jun 11 '20 at 15:00
  • @Andy Your answer and that post solved the most of my problem. So it is a possibility that two threads running in two different physical cores, or one thread is running while other is preempted. SO I have one last question regarding to "_sub-architectural levels to offer threads the functional units of the core the other thread is not using_", given a particular physical core, only one logical core is running on it, not both its logical cores? Is it correct? – Neminda Prabhashwara Jun 12 '20 at 06:34
  • Two logical cores per physical core – Andy Jun 12 '20 at 07:17
  • @Andy Yes I asked that can only one logical core be run at a time in a physical core? – Neminda Prabhashwara Jun 12 '20 at 11:34
  • Work is combined from both logical cores in some optimized strategy, most of which is below the architectural definition of the processor. Basically Intel/AMD have some ways of figuring out how to schedule two threads of work on the same processor core at the same time. – Andy Jun 12 '20 at 16:25
  • @Andy Now I get some idea thank you very much. I really really appreciate you. – Neminda Prabhashwara Jun 16 '20 at 17:25

0 Answers0