1

I have a single-board computers that runs on a rooted android version. I have an application that uses opencv that demands much CPU usage. Sometimes the performace of the application falls because another process is running on android OS. I wonder is there a way to change the priority of the thread of my application to avoid losing performace. I know that for version not rooted, this is not possible, but for rooted version is there any way to do this?

2 Answers2

0

On Linux you can do that with the command nice. You must use a negative parameter to increase the priority, and you must be root for this:

nice --20 name_of_your_command

To change the priority of a running process you can use renice.

Sleafar
  • 1,486
  • 8
  • 10
0

Use renice command, you can change the priority of process. Android use Completely fair queue to schedule process.
For creating new process and change its priority:

    nice -n 10 command   

    #means start command and set its nice value to 10

For processes already running:

    toybox renice -p pid -n 10
    #means change the pid process nice value to 10, toybox is for Android M

Nice value is between -20 to 19, ps -t -p would show all the process nice value:

USER      PID   PPID  VSIZE  RSS  PRIO  NICE  RTPRI SCHED  WCHAN            PC  NAME

root      1     0     1372   780   20    0     0     0     SyS_epoll_ 00000000 S /init

root      2     0     0      0     -2    0     1     1       kthreadd 00000000 S kthreadd

For Non real time process, PRIO = 20 + NICE, smaller value ,higher priority

Jiangty
  • 292
  • 1
  • 6