How can the OS use all the cores for my application?

I have COM written in Delphi 101 Berlin. And I am writing a script to call my API (only one API, single-threaded, and each takes about 1 minute to complete).

I am running the vbs file using cscript.exe (64-bit) (and here I am using a simple desktop ), many copies (so there are many processes) at the same time.

Nevertheless, I tested on many PCs (Windows 10 Pro), and it is observed that only about 1 core works, despite the fact that many of them have many cores.

For example, on my two processors ( HPZ800 Intel Xeon X5650 , 6 cores each = 12 cores), only 1 core is used,

If some scripts come out from an early time, then the use of the rest of the processors will be improved, but all together are added up to no more than 1 core.

My question is: how to write code to benefit from multiple cores?

enter image description here

+5
source share
1 answer

For the simultaneous use of multiple cores, multiple threads are required. The converse is not true!

To really take advantage of the multi-core system, the application must divide the main processing into several threads. these algorithms must be parallelized.

Source: https://scalibq.wordpress.com/2012/06/01/multi-core-and-multi-threading/

My COM API is single threaded. Therefore, several processes do not allow the OS to use all the cores. As explained in the comments, if each process simply falls asleep for 60 seconds, there is no way to eliminate all the cores.

I have another API with a fully multi-threaded interface, and it can use all cores even with one process.

In addition, it is mentioned that if there is I / O competition or several processes fighting for the same resources, this will affect the use for cores.

Refresh . I’m doing some experiments, and it turns out that a single-threaded process can use no more than one core, however, launching several of them can use all the kernels that the OS can really solve, see My experiments for more details. When can Windows use all the kernels?

0
source

Source: https://habr.com/ru/post/1262768/


All Articles