In standard multi-tasking Linux environments, the Completely Fair Scheduler (CFS) dynamically allocates CPU cycles across user applications, balancing throughput and interactive responsiveness. However, time-critical workloads—such as low-latency audio processing (JACK, PipeWire), industrial data acquisition, financial algorithmic trading engines, and robotics control loops—cannot tolerate scheduling latency or thread preemption. Part of the util-linux suite, chrt allows administrators and engineers to inspect and modify POSIX real-time scheduling policies and static priority levels directly from the command line.
Understanding Linux Real-Time Scheduling Policies
The Linux kernel supports multiple distinct scheduling classes. When assigned real-time scheduling attributes, processes preempt all normal user space tasks, executing immediately whenever data is available:
- SCHED_OTHER / SCHED_NORMAL (
-o): The default, time-sharing CFS policy. It dynamically adjusts priorities based on nice values (-20 to 19). - SCHED_FIFO (
-f): First-In, First-Out real-time policy. A FIFO process runs continuously until it voluntarily blocks on I/O, yields the CPU, or is preempted by a higher-priority real-time thread. - SCHED_RR (
-r): Round-Robin real-time policy. Similar to FIFO, but threads sharing identical priority levels are allocated fixed execution timeslices (quantum), ensuring fair CPU distribution among real-time peers. - SCHED_BATCH (
-b): Optimised for CPU-intensive background batch computation, reducing wakeups to maximize processor cache hits. - SCHED_IDLE (
-i): Extremely low priority; processes execute exclusively when no other thread demands CPU resources. - SCHED_DEADLINE (
-d): Earliest Deadline First (EDF) scheduler enforcing strict mathematical runtime, deadline, and period guarantees.
Querying Process Scheduling Attributes and Priority Ranges
Before modifying process attributes, inspect the minimum and maximum priority boundaries supported by your active kernel:
chrt -m
On Linux systems, SCHED_FIFO and SCHED_RR support static priority levels ranging from 1 (lowest real-time priority) to 99 (highest real-time priority).
To inspect the current scheduling policy and priority of an existing running process by PID:
chrt -p 14205
The terminal outputs the current scheduling policy and static priority value:
pid 14205's current scheduling policy: SCHED_OTHER
pid 14205's current scheduling priority: 0
Launching a New Process with Real-Time Priority
Manipulating real-time attributes requires CAP_SYS_NICE capability or root privileges. To launch an audio processing daemon with Round-Robin scheduling at priority 50:
sudo chrt -r 50 /usr/bin/jackd -d alsa
The kernel immediately places the newly spawned thread into the real-time scheduling runqueue.
To launch a high-frequency telemetry collector using FIFO scheduling at priority 80:
sudo chrt -f 80 /opt/telemetry/collector --interface=eth0
Modifying the Scheduling Policy of a Running Process
You can adjust the real-time attributes of an active daemon on the fly without interrupting its execution. To elevate a running process (PID 4821) to Round-Robin priority 40:
sudo chrt -r -p 40 4821
To demote a process from real-time status back to standard default time-sharing scheduling (SCHED_OTHER), set its priority to 0:
sudo chrt -o -p 0 4821
Configuring Real-Time Throttling to Prevent System Lockups
A rogue real-time thread running an infinite loop can starve all other operating system processes—including SSH daemons, the GUI desktop, and kernel watchdogs—causing a hard freeze. To prevent complete system starvation, the Linux kernel enforces RT throttling by default:
cat /proc/sys/kernel/sched_rt_period_us
cat /proc/sys/kernel/sched_rt_runtime_us
The default allocation reserves 950,000 microseconds (95%) of every 1,000,000-microsecond period for real-time processes, guaranteeing that 5% of CPU time remains available for emergency root terminal access and kernel housekeeping.
Essential chrt Command Switch Reference
| Command Option | Operational Behavior |
|---|---|
chrt -p [PID] |
Queries the active policy and priority of a running process. |
chrt -m |
Displays minimum and maximum valid priority boundaries. |
chrt -f [Prio] [Cmd] |
Launches a new command with SCHED_FIFO scheduling. |
chrt -r [Prio] [Cmd] |
Launches a new command with SCHED_RR scheduling. |
chrt -f -p [Prio] [PID] |
Changes an existing process to SCHED_FIFO priority. |
chrt -o -p 0 [PID] |
Reverts an existing process to standard SCHED_OTHER. |
chrt -v |
Displays verbose debugging output during execution. |