Home > Software engineering >  Multi-threading CPU utilization, sometimes high sometimes low
Multi-threading CPU utilization, sometimes high sometimes low

Time:10-07

I write for more than a batch processing program, using four threads, dealing with the first batch run end of the 20 s, about 90% CPU utilization, from after the second batch to batch is essentially 40 s, about 50% CPU utilization, and the results, this may be what causes?

CodePudding user response:

Sometimes high sometimes low
It's normal
Thread will be awakened by the operating system control

CodePudding user response:

Oh, thanks, is there any way to improve the utilization rate of CPU, and is basically dealing with the first time is fast, the batch processing time and CPU utilization is very stable, using multithreading is hoped to improve the efficiency of the algorithm,

CodePudding user response:

Improve the thread priority, at the same time, set the number of threads you is about 2 times of CPU cores to improve performance

CodePudding user response:

For dual-core CPU support four thread, I also used in the four threads, all threads and set to the highest priority, still is this effect

CodePudding user response:

Improve your thread priority, even end off other accounts for the CPU program (not recommended)

CodePudding user response:

Check your thread scheduling, 50% means that you are likely to only one thread in work,

CodePudding user response:

The building Lord, if it is double CPU open two worker threads works best

CodePudding user response:

Search "Mao Decao thread scheduling." "
  • Related