0

I am running Ubuntu basic server with two processes: - process 1 - performing calculation 100% of uptime, and which I use to share computing power to community (it's running @ prio 19) - process 2 - performing calculations for 5-10mins, from time to time, which I use to compute for me (it's running @prio -19)

I want process 2 to be given with 100% of computing power (process 1 is at that moment should get close to 0% of CPU).

I have tried to use nice / renice and process 1 is given with prio 19 (lowest possible) and process 2 is given prio -19 (highest possible). But best what I get is 50% of CPU for process 1 and 50% of CPU for process 2 (checked with htop) - which kind of surprised me...

Both processes are multithreaded, and - when running alone - consume 100% of all cores of CPU. No other resources (I/O, memory, bandwidth, ...) can influence this usage.

I don't want to manually stop/start any process when I need computing power (both processes must be running all the time); 100% of CPU for process 2 must be given automatically.

What should I do to achieve my goal? Thanks.

  • 1
    Are you sure your process 2 can even use 100% of your CPU? E.g. if it's single-threaded but you have two cores, it will at most use one core fully, so 50% in total. Or if it's bound by IO (network, disk, memory, ...) adding more CPU capacities would not help either. In theory adjusting the niceness of the process you want to give up its time share (1) should be enough to let the other one (2) take what it can. Have you tested how process 2 behaves if it's the only thing running? – Byte Commander Oct 9 '19 at 15:29
  • 1
    Yes, as it is multithreaded, and - when running alone - consumes 100% of CPU (=all cores) for all the time is is performing calculations. – remi Oct 9 '19 at 15:30
  • Check what the schedtool package offers, but you may need a different scheduler, one that's not so "fair". – ubfan1 Oct 9 '19 at 15:52
  • thanks @ubfan1 - following your suggestion to play with schedtool, and after reading some material about kernel scheduler, I managed to get almost what I wanted. – remi Oct 9 '19 at 21:54
0

Thanks to @ubfan1 I have explored different scheduling strategies, and here is the best result I have achieved so far:

  • process 1 is running with SCHED_BATCH policy

  • process 2 is running with SCHED_RR policy

results: when both processes are running simultaneously: - process 1 is given with ca. 5% of CPU - process 2 is given with ca. 95% of CPU

and when only process 1 is performing calculations (process 2 is waiting for my input to start calculations) - process 1 is using 100% of CPU

If someone is interested more, read this:

  1. http://manpages.ubuntu.com/manpages/xenial/man8/schedtool.8.html
  2. http://man7.org/linux/man-pages/man7/sched.7.html
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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