When the kernel is configured for realtime scheduling, processes can have a realtime priority value as well. A process with realtime priority will always be served before processes without realtime priority. In addition, the process is able to use the CPU as long as it needs (unless it is preempted by a realtime process with higher priority), and it is responsable for releasing the CPU again, so that other processes get a chance to run. Realtime priority values range from 0 to 99 (or 1 to 100). Processes with higher values will be run before processes with lower values. Originally, only the root user was able to run a process with realtime priority. But over time, a number of mechanisms were developed to give normal users this possibility as well. With earlier kernels the 'realtime-lsm' module was used. When this module was loaded, you could give a group on the system the right to run programs with realtime priorities. This method is now depreciated, and replaced with a different (and more flexible) method. This method makes use of PAM (pluggable authentication modules). PAM is used on many Linux systems to provide a common interface to different authentication methods (authentication is about login mechanisms, passwords etc.). PAM has a number of configuration files, and an important one for our purpose is "/etc/security/limits.conf". This file imposes limits upon users or groups on the system, and one of these limits is the maximum realtime priority a user or group can get. Other useful limits for audio work are the minimum nice value (maximum priority) and the maximum size of memory that can be locked. An example of a "limits.conf" file could be:
@audio - rtprio 99
@audio - nice -19
@audio - memlock 512000
Here we are specifying certain limits for the audio group (@ means group, if you leave it out the limit will apply to a user). With this file, users that are part of the audio group will be able to run programs with maximum realtime priority, maximum nice priority, and a maximum memlock size of 512000 Kb.