Is there a way to limit CPU usage in C++?
I mean can I write a program which takes input %CPU to be used and it uses maximum that much amount of CPU.
I basically want to add the functionality of cpulimit command internally in the program.
If there is, how to do it ?
Edits:
Environment: Linux (debian) with gcc 6.1. It should support as many arbitrary numbers as possible. i.e a range of 1% - 100% . If the OS cannot do, an error can be logged and the nearest value to it can be used or any other solution that is recommended when the OS restricts that number.