Instruction assignment with multiple CPUs

2

Maybe this is a stupid question but I am trying to gain a better understanding of hardware inner workings...

If a machine has two or more CPUs, which hardware component is actually responsible for distributing instruction execution (process- or thread-level) among different CPUs? Or another way to put it, what determines which CPU does what once an instruction set arrives? Is there something equivalent to a load balancer that distributes workload in a cluster computing environmet.

Thanks

amphibient

Posted 2012-12-06T18:36:23.630

Reputation: 1 613

1Each core receives its own stream of instructions. The consecutive stream of instructions that constitutes a single thread of execution go to only a single core. If multiple cores are active at the same time, each is following its own stream of instructions that exist in the software that core is running at that time. The scheduler (part of the OS) assigns instruction streams to cores. – David Schwartz – 2012-12-06T18:49:48.183

Answers

2

The operating system creates "threads" or "tasks" for each sequential unit of work (ie, a simple program). The OS keeps a queue of threads/tasks that are ready to run and, each time a CPU becomes available, the OS assigns a "ready" thread/task to it.

A CPU becomes available because the previously-executing thread/task ended, or because it needs to wait for disk I/O or network response or user input or whatever. When a waiting thread/task has satisfied the reason for its wait, it gets put back in the "ready" queue.

In essence, each thread/task is a "virtual CPU", and the OS assigns these "virtual CPUs" to real CPUs.

Daniel R Hicks

Posted 2012-12-06T18:36:23.630

Reputation: 5 783

1

It's a combination of the Operating System and the control unit in the CPU. The OS is responsible for creating threads and assigning them to cores. The control unit in the CPU directs the flow of data inside of the processor. It can re-order commands and dynamically assign them to different logic units.

Brad Patton

Posted 2012-12-06T18:36:23.630

Reputation: 9 939