0

I've got a program that I want to limit the CPU usage of (yes, I've set the process priority and yes it's optimized). It always takes up 100% CPU power, it's CPU bound, and its workload will never finish.

I want to limit the usage of this process to 30% CPU usage, and the only way I've found to do this in a Windows application is to periodically have the program sleep. Here is the resulting CPU usage:

CPU Usage

The CPU usage shown above is over the course of one second. If you take the average value of that graph, it is ~32% (the target was 30). In fact, task manager reports the process is using between 25-35% CPU usage at any time.

My program may be run on notebooks, where the user may not want their fans to turn on for a background process. Also, many notebooks have a power-saving state for their CPUs, and I don't want my program to remove the CPU from its power-saving state. Will the constantly fluctuating CPU usage shown above turn on the fans of a notebook or remove it from its power saving state (the usage can be reduced to 15% or even less, but it still produces fluctuations from 100% to 0%).

Hennes
  • 64,768
  • 7
  • 111
  • 168
Byte11
  • 101
  • 3
  • Have you tried Threadmaster? https://superuser.com/a/692192/449623 or BES? https://superuser.com/a/214572/449623 I know they're old, but may still work. – qasdfdsaq May 30 '18 at 20:59
  • @Byte11 , just to confirm, are you the developer of the program? You mentioned "my program" and "the user" in the question. SuperUser is a good place for end users and administrators to find answers, but you may want to use StackOverflow instead. – Christopher Hostage May 30 '18 at 21:27
  • @ChristopherHostage Yes, I am. I was about to use StackOverflow, but this has more to do with hardware and general CPU usage than my program or even what language I'm using. I figured that if you don't even need to know the programming language, StackOverflow is the wrong place. – Byte11 May 30 '18 at 22:42
  • @qasdfdsaq Threadmaster simply shuts off certain cores. I want to be able to limit my program with more precision than that. I'm looking into how BES works, but most programs like it also operate on the suspend program and resume program system I'm using. Since BES is so old, many power-saving notebook CPUs weren't a thing back then, and I don't know how such applications would affect the computer. – Byte11 May 30 '18 at 22:44
  • @Byte11 , are you going to instruct all of your customers to run a 3rd party program to limit your program? I don't know how you're going to distribute your program, but if it's going to be downloaded from a public website, then most users will ignore the instruction. Don't overcomplicate it - put the control inside your own executable. Many programming languages include a sleep() function or other ways of accomplishing waiting. – Christopher Hostage May 31 '18 at 17:01
  • @ChristopherHostage Yes, that's what I'm doing and it produces the above result. – Byte11 May 31 '18 at 17:01

0 Answers0