I have an application written in C++ on Linux (Ubuntu 12.14), which decodes audio and finds the peak. This calculation is running on a background thread. From the main UI thread, I am calling the background thread several times. When this background thread runs, I see about 100% CPU utilization; that is, only the first core's usage goes 100%, and the remaining 3 cores are idle (quad core processor).

So is it good behavior for the application to utilize 100% CPU? I read some post which states, "Usually it's a good thing for a process to use 100% of the CPU. It means it finishes sooner."

Another statement I've read is, "75% to 100% cpu usage is not too bad if you're getting this under full load or when there's a major application running; however if this is a reading when idle or when you are not using the PC/laptop then this is a worry."

  • you should ask this at ux.stackexchange.com not here. – Sam Apr 13 '16 at 20:40
  • 3
    @Sam, this has nothing to to with ux... he's asking if it's ok for his program to tie up 100% of the cycles on one core. – Ryan Apr 13 '16 at 22:22
  • @ryan How is the user experience going to be if he locks up the computer? He is literally asking "Should I lock up the computer, or will the users experience be degraded." – Sam Apr 13 '16 at 23:34
  • @Sam are you aware that you can control how much CPU a process gets? Plus, would probably have no idea what he's talking about. – MatthewRock Apr 14 '16 at 0:07
  • @MatthewRock how do you control how much CPU a process gets? The only thing I am familiar with is controlling process priority. – Sam Apr 14 '16 at 13:37

It depends on whether your application is a computational one (like this) or interactive.

For a computational application, full utilisation of the CPU(s) is your goal, as that means that the result is ready sooner. Anything that causes that utilisation to go down is an opportunity for improvement (e.g. waiting on I/O).

For an interactive application, any time used in CPU is time that's not spent ready to respond to user input. You would like your usage to be low.

Some applications, such as multimedia editors, are both computational and interactive. The good ones divide the work into different threads, so that they can be responsive to interaction, yet achieve high throughput. This appears to be what you're doing.

One thing you might want to consider is using more threads for your workload (assuming it is divisible) so that you are keeping more cores busy with your computation. If some of them are idle, that's a wasted resource!

  • You are right, my application is computational + interactive, that record the video/audio on background, the main thread display the live feed in a window, also when user decides the background process mentioned above start and do computation to find the audio peak. – Haris Apr 13 '16 at 17:47
  • 1
    Of course, if you want to run a computational program in the background while you use other programs interactively, you'll want to reduce its priority (nice value), so that it will take all available CPU, but not stall out other programs. – jpaugh Apr 13 '16 at 21:49

Of course it's good. The CPU's sole raison d'être is to be used by applications. The entire hw+os combo exists for this single purpose. Why wouldn't it be good to consume as much cpu as there is in the system?

  • 1
    well, devil's advocate, it's bad to consume all of the CPU (by that I mean %100 all cores) on an application commonly run in the background. If your app uses it something else cannot. – Centimane Apr 13 '16 at 17:08
  • That's not always the case. Give the CPU-hog a high nice value, so that other programs are preferred. – jpaugh Apr 13 '16 at 21:50

The purpose of the operating systems is to handle this for you, Windows, Mac OS, Linux, the two fundamental purposes of all of them are scheduling and hardware interface. This question has nothing to do with Linux or Unix.

Not the answer you're looking for? Browse other questions tagged or ask your own question.