Setting PR and NI for a PID
PR
To set the scheduling policy of a Linux process to real-time using a command in Ubuntu, you can use the chrt
command followed by the real-time priority level and the process ID (PID) of the process you want to modify.
Here's an example command that sets the priority of a process with PID 1234 to real-time priority 10:
sudo chrt -f -p 99 1234
Here, the -f
option sets the scheduling policy to SCHED_FIFO
, which is a real-time policy, and the -p
option sets the real-time priority level to 99. The 1234
at the end is the PID of the process you want to modify.
Note that setting a process to real-time scheduling policy can have significant effects on system performance and should be done with caution. It's also important to note that only processes started by the root user can be set to real-time scheduling policy.
NI
renice
is a command in Linux that allows you to change the priority of an already running process. The renice
command allows you to adjust the nice value of a process, which is a value between -20 and 19, with lower values indicating higher priority.
To use the renice
command, you need to know the process ID (PID) of the process you want to change the priority of. You can find the PID of a process using the ps
command or the top
command.
The basic syntax of the renice
command is as follows:
renice [-n] priority [-g|-p|-u] id
Here, priority
is the new nice value you want to set for the process, and id
is the PID of the process you want to change the priority of. You can use the -g
, -p
, or -u
option to specify whether id
refers to a process group, a process ID, or a user ID, respectively.
For example, to set the nice value of a process with PID 1234 to 10, you can run:
sudo renice -n -20 -p 1234
This will increase the priority of the process with PID 1234 by setting its nice value to -20.
Note that setting a process to a high priority level can have a significant impact on the overall system performance and stability. It's important to ensure that the process you're modifying is a critical process that requires the highest priority level.