SCHEDTOOL(8)
๐ธ SCHEDTOOL(8) ๐ธ
okay so bestie, welcome to SCHEDTOOL(8) from the System Manager's Manual โ it's literally your CPU scheduling bestie, and it's giving main character energy ๐
โจ NAME โจ
schedtool โ query and set CPU scheduling parameters ๐
โจ SYNOPSIS โจ
schedtool
[-0|-N] [-1|-F] [-2|-R] [-3|-B] [-4|-I] [-5|-D]
[-M policy]
[-a affinity]
[-p prio]
[-n nice_level]
[-e command [arg ...]]
[-r]
[-v]
[-h]
[LIST OF PIDs]
โจ DESCRIPTION โจ
okay so schedtool can set all the CPU scheduling parameters Linux is capable of, or it can display information for given processes. no cap ๐
Long-running, non-interactive tasks may benefit from SCHED_BATCH because timeslices are longer, less system-time is wasted by computing the next runnable process, and the caches stay stable. obsessed with a stable cache, honestly. โจ
Audio/video or other near-realtime applications may run with less skipping if set to SCHED_RR. Use the static priority-switch -p to designate inter-process-hierarchies. ๐ง
schedtool now supports setting the CPU-affinity introduced in linux 2.5.8. iconic behavior. ๐ฆ
๐ OPTIONS ๐
-Nor-0โ set all PIDs toSCHED_NORMAL/OTHER๐-For-1โ set toSCHED_FIFO; root-credentials required ๐ฅ-Ror-2โ set toSCHED_RR; root-credentials required ๐-Bor-3โ set toSCHED_BATCH๐ง-Ior-4โ set toSCHED_ISO๐ฎ-Dor-5โ set toSCHED_IDLEPRIO๐ด-M policyโ for manual/raw mode;policyis the number of the scheduling policy (see above for0-4). This option is mostly for kernel guys that want to test their new implementations. ๐งช-p prioโ specify static priority required forSCHED_FIFOandSCHED_RR. Usually ranged from1-99. โก-a affinityโ set the PID's affinity to this bitmask (hexadecimal); alternatively, a list mode is supported. ๐งญ-n nice_levelโ set the PID's nice level; seenice(2),nice(1). ๐-e command [arg ...]โ executecommandwith given scheduling parameters (overwrites schedtool's process image). See EXAMPLES. ๐-rโ display min and max priority for each policy. ๐-vโ be verbose. ๐ฃ๏ธ-hโ help. ๐
๐ EXAMPLES ๐
To query the $SHELL's policies:
#> schedtool $$
To query some PIDs, namely 1 2 and 3:
#> schedtool 1 2 3
To execute mplayer in SCHED_RR with priority 20. The priority arg is needed for both SCHED_RR and SCHED_FIFO.
#> schedtool -R -p 20 -e mplayer -quiet some_file.avi
To set current shell to SCHED_BATCH, which all programs the shell starts will inherit:
#> schedtool -3 $$
To set all processes with the name 'cpu_hog' to SCHED_BATCH:
#> schedtool -3 `pidof cpu_hog`
To set a process' affinity to only the first CPU (CPU0):
#> schedtool -a 0x1 <PID>
Using the list mode and affinty of CPU0 and CPU3:
#> schedtool -a 0,3 <PID>
A combination of an affinity and a policy-argument is - of course - always possible.
#> schedtool -B -a 0x1 <PID>
๐ AFFINITY MASK ๐
The affinity-argument determines on which CPUs a process is allowed to run. It consists of a simple bitmask represented in hexadecimal. CPU0 is denoted by the least-significant bit, CPU1 by the second least-significant and so on, thus giving:
0x1 -> only run on CPU0
0x2 -> only run on CPU1
0x4 -> only run on CPU2
0x8 -> only run on CPU3 ... and so on.
Multi-target CPUs may be specified using bitwise OR of the values:
0x7 -> run on CPUs 0, 1, 2 but NOT on 4
0x3 -> run only on CPUs 0 and 1
The default is to run a process on all CPUs, giving a mask of:
0xf for all 4 CPUs
0xff for all 8 CPUs
๐ฆ AFFINITY MASK - LIST MODE ๐ฆ
Alternatively a list mode is supported where you can specify the CPUs delimited by ,. The following runs <PID> on CPU0 and CPU1 (equivalent to 0x3):
#> schedtool -a 0,1 <PID>
๐ POLICY OVERVIEW ๐
SCHED_NORMAL / SCHED_OTHERโ This is the default policy and for the average program with some interaction. Does preemption of other processes. ๐SCHED_FIFOโ First-In, First Out Scheduler, used only for real-time constraints. Processes in this class are usually not preempted by others, they need to free themselves from the CPU viasched_yield()and as such you need special designed applications. Use with extreme care. ROOT-credentials required. ๐SCHED_RRโ Round-Robin Scheduler, also used for real-time constraints. CPU-time is assigned in an round-robin fashion with a much smaller timeslice than withSCHED_NORMALand processes in this group are favoured overSCHED_NORMAL. Usable for audio/video applications near peak rate of the system. ROOT-credentials required. ๐งSCHED_BATCH[ since 2.6.16 in mainline ] โSCHED_BATCHwas designed for non-interactive, CPU-bound applications. It uses longer timeslices (to better exploit the cache), but can be interrupted anytime by other processes in other classes to guaratee interaction of the system. Processes in this class are selected last but may result in a considerable speed-up (up to 300%). No interactive boosting is done. ๐งSCHED_ISO[ patch needed ] โSCHED_ISOwas designed to give users aSCHED_RR-similar class. To quote Con Kolivas: "This is a non-expiring scheduler policy designed to guarantee a timeslice within a reasonable latency while preventing starvation. Good for gaming, video at the limits of hardware, video capture etc." ๐ฎSCHED_IDLEPRIO[ patch needed ] โSCHED_IDLEPRIOis similar toSCHED_BATCH, but was explicitly designed to consume only the time the CPU is idle. No interactive boosting is done. If you usedSCHED_BATCHin the-ckkernels this is what you want since 2.6.16 ๐ด
๐ง HINTS ๐ง
PID 0means "current process", in our case,schedtool. May occur when using the-eswitch. ๐ซถ- > Be careful with
SCHED_FIFO! You may lock out other processes from the CPU, including your shell. ๐ญ - For
SCHED_BATCHyou certainly need the a recent 2.6 kernel. ๐ฑ - A short overview is given in
SCHED_DESIGNand theREADMEcontains thorough discussion. TheINSTALLfile also lists all prerequisites and where you can get patches. ๐ - > Affinity
0x0should never be used. ๐ซ
๐ SEE ALSO ๐
sched_setscheduler(2), sched_setaffinity(2), nice(2), nice(1), renice(3).
๐ BUGS ๐
You need some knowledge about the kernel and scheduling. The author is a grumpy little elitist. ๐ญ
๐ AUTHOR ๐
Freek
Please contact me via freshmeat.net's "contact author"-feature (http://freshmeat.net/projects/schedtool). ๐ฌ
and that's a wrap from the System Manager's Manual, dated 1 November 2006, filed under SCHEDTOOL(8) โ mwah ๐
๐ฆ where this page comes from
- debian bookworm: schedtool 1.3.0-4 ยท GPL-2.0-only
- debian trixie: schedtool 1.3.0-5 ยท GPL-2.0-only
- ubuntu jammy: schedtool 1.3.0-4 ยท GPL-2.0-only
- ubuntu noble: schedtool 1.3.0-4 ยท GPL-2.0-only
- ubuntu questing: schedtool 1.3.0-5
- ubuntu resolute: schedtool 1.3.0-5build1 ยท GPL-2.0-only
- ubuntu stonking: schedtool 1.3.0-5build1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms