5

Calling ulimit -a returns the following:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1895
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1895
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

What does the -r (real-time) option do?

1 Answers1

1

TL-DR: it is the highest (=most urgent) priority that shell-spawned processes can be assigned by the scheduler.

Wordy explanation

ulimit gives control over the resources available to the shell: it reports and/or sets such limits.

The -r flag reports the highest priority to be assigned for scheduling to a process spawned by the shell. Since priorities run from 0 (most urgent) to 99 (least urgent), this means that processes spawned by the shell (those belonging to the real-time application classes) can achieve the highest scheduling priorities.

Processes are classified either on the basis of their use of resources (I/O-bound or CPU-bound, depending upon whether they mostly use I/O or CPU resources) or, more relevantly here, on the basis of their degree of urgency (a non-technical expression). There are interactive processes like the shell: since we humans are slow and dumb, the pc wastes a lot of time waiting for us to even lift a finger. However, once a key has been pressed, these processes need to be given high priority unless we feel the system to have become unresponsive; the average delays must be of order 50msec or so, and with small variance.

There are also batch processes, which do not need user interaction, run mostly in the background, hence are given low priority by the scheduler. A typical example are scientific computations.

Lastly, there are real time processes which impose the strictest constraints on the scheduler. In this category fall video and audio recordings and playback, data collection from physical sensors, robot controllers. These processes must be given the highest priority to allow them to carry out their tasks.

The fact that such priority, as reported by ulimit, is 0 does not mean that this is necessarily 0: 0 is the hard limit, you can set a soft limit at smaller values, and you can increase the priority up to the value of the hard limit, which however in this case also coincides with the maximum available in the system.

MariusMatutiae
  • 48,517
  • 12
  • 86
  • 136