This is what ChatGPT-4 had to say about real-time (audio) and different types of CPU priorities.

  • Status: [✔️] Verified by @gkiagia:matrix.org in #pipewire:matrix.org (Thank you!)

user: What's the difference between a process' CPU priority and a realtime priority?

CPU priority (also known as niceness in Unix-like systems) and real-time priority are two different ways of determining how much CPU time a process should receive. However, they operate in different ways and have different implications for system performance.

CPU Priority (Niceness):

  • The CPU priority, or "niceness", of a process in Unix-like operating systems is a value that determines how "nice" the process is being to others, in terms of sharing the CPU.
  • A process with a high niceness value is "nice" in that it yields CPU time to other processes, while a process with a low niceness value is "not nice" because it takes more CPU time for itself.
  • The niceness value can range from -20 (highest priority, or least nice) to 19 (lowest priority, or most nice).
  • Normal user processes usually have a niceness value of 0.

Real-time Priority:

  • Real-time priority is a different type of scheduling processes are usually time-sensitive, such as audio processing or data collection programs.
  • When a process has real-time priority, the scheduler (which determines how processes share the CPU) will try to ensure it gets CPU time ahead of other non-real-time processes, regardless of their niceness values.
  • Real-time priority can be further divided into two scheduling policies: FIFO (First In, First Out) where processes run until they are finished, and RR (Round Robin) where processes run for a fixed amount of time before moving to the next process.
  • The priority level for real-time tasks is usually from 1 (lowest priority) to 99 (highest priority).

Generally, real-time priority is powerful but needs to be used with caution. A misconfigured real-time application could consume all available CPU time and render the system unresponsive.

user: So in other words, process niceness is about the amount-based CPU priority while realtime priority is time-based?

Yes, that's a good way to put it.

Niceness or CPU priority is about allocating the amount of CPU resources among competing processes. A lower niceness value (i.e., a higher CPU priority) means the process is less "nice" to others and claims more CPU resources for itself. This is amount-based prioritization.

On the other hand, real-time priority is about meeting time constraints. It's more about when a process gets the CPU time, rather than how much it gets. The scheduler will interrupt other tasks if necessary, to ensure that a real-time process gets CPU time when it needs it. This is time-based prioritization.

So yes, they're two different dimensions of scheduling, and they can be used separately or together according to the needs of the specific tasks running on the system.