Master Linux Scheduling: Real‑Time, Normal, Batch & Idle Policies Explained
This article explains Linux's real‑time and general scheduling policies—including SCHED_RR, SCHED_FIFO, SCHED_NORMAL, SCHED_BATCH, and SCHED_IDLE—describes their behavior, and demonstrates their impact on CPU allocation through practical chrt command tests.
Linux provides several scheduling policies for both real‑time and non‑real‑time processes. The real‑time policies include SCHED_RR (round‑robin, each process gets a maximum CPU time slice) and SCHED_FIFO (first‑in‑first‑out, a process runs until it blocks, yields, or is pre‑empted by a higher‑priority task).
SCHED_NORMAL is the default policy for regular processes, implementing a standard round‑robin algorithm. SCHED_BATCH is tuned for batch jobs such as data compression; it avoids pre‑emption to improve cache usage. SCHED_IDLE is for very low‑priority tasks (nice value less than 19).
Example commands to inspect the system: lscpu Sample output shows a dual‑CPU x86_64 system with two sockets, each with one core.
Testing the policies with chrt:
# chrt -f 10 top
# chrt -f 1 md5sum /dev/zero &
# chrt -r 1 sha1sum /dev/zeroObservations: the md5sum process run with SCHED_FIFO (priority 1) consistently occupied the CPU ahead of top. When using the round‑robin policy ( SCHED_RR) for sha1sum, the process was not visible in top, indicating it was not scheduled as aggressively.
These experiments demonstrate how different scheduling classes affect CPU allocation and process visibility.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
