Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a single threaded application run on only one CPU

I am developing a single threaded application on an 8 CPU machine and when a heavy operation happens the CPU utilization appears like this :

enter image description here

Does the .NET framework have some facility to divide the work of that single thread (automatically) into the other CPUs ?

like image 413
user4032346 Avatar asked Dec 19 '14 00:12

user4032346


People also ask

Can a single thread process run on multiple cores?

There is no such thing as a single thread running on multiple cores simultaneously. It doesn't mean, however, that instructions from one thread cannot be executed in parallel. There are mechanisms called instruction pipelining and out-of-order execution that allow it.

Can a threads be run on multiple CPUs?

The answer is: It depends. On a system with multiple processors or CPU cores (as is common with modern processors), multiple processes or threads can be executed in parallel. On a single processor, though, it is not possible to have processes or threads truly executing at the same time.

How many threads can run on a single CPU?

A single CPU core can have up-to 2 threads per core. For example, if a CPU is dual core (i.e., 2 cores) it will have 4 threads. And if a CPU is Octal core (i.e., 8 core) it will have 16 threads and vice-versa.

What does single threaded mean in CPU?

Single threaded processes contain the execution of instructions in a single sequence. In other words, one command is processes at a time. The opposite of single threaded processes are multithreaded processes. These processes allow the execution of multiple parts of a program at the same time.


2 Answers

It's not guaranteed that any single thread will always run on the same core. But it's guaranteed that it will run only on one core at the same time. But it can run on one core till context switch, and resume after the context switch on another core. Each time-slice, your thread gets, may be allocated on another core.

like image 156
Denis Itskovich Avatar answered Sep 17 '22 23:09

Denis Itskovich


Does a single threaded application run on only one CPU?

As others have noted, not necessarily. However, a given thread will only run on one core at a time.

Does .net framework have some facility to divide the work into the other CPUs?

Yes. .NET has the Parallel class and Parallel LINQ. Note that you have to divide up the work yourself (into small pieces), and then the .NET framework will handle balancing the work between multiple threads automatically.

like image 21
Stephen Cleary Avatar answered Sep 19 '22 23:09

Stephen Cleary