Real time processes scheduling in Linux
Question 1
It is possible for an user to use real time priority for a process as well. This configuration could be set from /etc/security/limits.conf
file. I see the below contents in that file.
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
If we check the item section, we see the below entry which enables to set a real time priority for the users.
# - rtprio - max realtime priority
Question 2 and Question 3
To set scheduling policy to SCHED_FIFO
, enter:
chrt -f -p [1..99] {pid}
To set scheduling policy to SCHED_RR
, enter:
chrt -r -p [1..99] {pid}
So to answer question 3, we should verify the scheduling algorithms available and the priorities using the chrt -m
command and then use any scheduling algorithm that suits our need. To set different priorities, we could use the commands as above.
Related videos on Youtube
Ramesh
Updated on September 18, 2022Comments
-
Ramesh over 1 year
I have been learning some scheduling concepts. Currently my understanding so far is as below.
- There are real time processes and non real time processes.
- Non real time processes can have
nice
values for their priority in the range of -20 to +20. The higher positive value indicates that the process has lower priority. - The real time processes will have a niceness value listed as
-
as explained in this answer here. This is mainly because the real time processes have higher priorities than the non real time processes and niceness value do not apply to them. - Now, I can use
chrt
to see the real time attributes of a process.
For a real time process, the
chrt
gives output as,chrt -p 5 pid 5's current scheduling policy: SCHED_FIFO pid 5's current scheduling priority: 99
As we can see for process 5, the priority is 99 which is the highest. Also, the scheduling policy is
SCHED_FIFO
Now, for a non real time process, the
chrt
gives output as,chrt -p 22383 pid 22383's current scheduling policy: SCHED_OTHER pid 22383's current scheduling priority: 0
As we can see for process 22383, the priority is 0 and the scheduling policy is
SCHED_OTHER
.Questions
- Is it possible for me to make any process as real time process?
- Is it possible for me to set some other scheduling algorithm other
than
SCHED_OTHER
for a non real time process? -
From here, I also see that I could modify the attribute for a running process as,
chrt -p prio pid
Also, I see
chrt -m
gives me the list of scheduling algorithms. The command gives me the output as,SCHED_OTHER min/max priority : 0/0 SCHED_FIFO min/max priority : 1/99 SCHED_RR min/max priority : 1/99 SCHED_BATCH min/max priority : 0/0 SCHED_IDLE min/max priority : 0/0
Now, as suggested above, if I set
chrt -p 55 22383
which algorithm will be used?