I use cscript.exe (64-bit) to run the vbs file (I use simple job runner here), and run many copies at the same time (so there are many processes).
But , I have tested on many PCs (Windows 10 Pro) and observed that only about 1 core is running, although it has many cores.
For example, on my 2 CPUs (HPZ800 Intel Xeon X5650, each 6 cores = 12 cores), only 1 core is used.
If some scripts exit early, the rest of the CPU usage will be improved, but not in total More than 1 core.
My question is, how to write code to benefit from multi-core?
In order to use multiple cores at the same time, multiple threads are
required. The inverse is not true!< /p>To really take advantage of a multi-core system, an application should
split up the main processing into multiple threads as well. Its
algorithms need to be parallelized.blockquote>
Source: https://scalibq.wordpress.com/2012/06/01/multi-core-and-multi-threading/
My COM API is single threaded. Therefore, multiple processes do not allow the OS to use all cores. As explained in the comments, if each process just sleeps for 60 seconds, it will not solve all core issues.
I have another completely more Thread API, even if there is only 1 process, it can use all cores.
In addition, it is also mentioned that if there is an I/O competition or multiple processes competing for the same resource, the core utilization will be Affected.
Update I did some experiments, and the results proved that a single-threaded process can use at most one core, but starting multiple cores can use all cores that are truly determined by the operating system. Please refer to my Experiment details When Can Windows Utilize All the Cores?
I have a COM written in Berlin Delphi 101. I wrote a script to call its API (only one API , Single thread, each takes about 1 minute to complete).
I use cscript.exe (64-bit ) Run the vbs file (I use simple job runner here) and run many copies at the same time (so there are many processes).
However, I have tested it on many PCs (Windows 10 Pro) and observed Until only about 1 core is running, although it has many cores.
For example, on my 2 CPUs (HPZ800 Intel Xeon X5650, 6 cores each = 12 cores), only use 1 core.
If some scripts exit early, the rest of the CPU usage will be improved, but not more than 1 core in total.
My question is, how Write code to benefit from multi-core?
< /p>
In order to use multiple cores at the same time, multiple threads are
required. The inverse is not true!To really take advantage of a multi-core system, an application should
split up the main processing into multiple threads as well. Its
algorithms need to be parallelized.
Source: https:// scalibq.wordpress.com/2012/06/01/multi-core-and-multi-threading/
My COM API is single-threaded. Therefore, multiple processes do not allow the OS to use all cores. As explained in the comments, if each process just sleeps for 60 seconds, it won’t solve all the core problems.
I have another fully multi-threaded API, even if there is only 1 process, it does All cores can be used.
In addition, it is also mentioned that if there is an I/O race or multiple processes competing for the same resource, the utilization of the core will be affected.
Update me Some experiments have been done, and it turns out that a single-threaded process can use at most one core, but starting multiple cores can use all cores that are truly determined by the operating system. Please refer to my experiment details When Can Windows Utilize All the Cores? p>