31

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

  1. Is it possible for me to make any process as real time process?
  2. Is it possible for me to set some other scheduling algorithm other than SCHED_OTHER for a non real time process?
  3. 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?

1
  • Static priority range 50-99 with real-time policy is a possible hazard. Default priority for hardware interrupts is 50. With RT sched, a task can only be interupted by a higher priority task or by voluntary yield/sleep (intermittent or short tasks). Eg. if you have an intensive calculation that will take 2 days and you set its sched priority to fifo 99 the computer will not respond until the task is complete 2 days later. With round-robin 99, p99 tasks will be rotated but nothing of lower priority will execute until all p99 are complete or sleeping.(¿Outcome from set both a fifo99 and a rr99?)
    – Max Power
    Commented Dec 30, 2023 at 20:32

1 Answer 1

24

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .