Long-running, non-interactive tasks may benefit from SCHED_BATCH as timeslices are longer, less system-time is wasted by computing the next runnable process and the caches stay stable.
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 $$ To query some PIDs, namely 1 2 and 3: #> schedtool 1 2 3To 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.aviTo 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>
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
#> schedtool -a 0,1 <PID>
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 via sched_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 with SCHED_NORMAL and processes in this group are favoured over SCHED_NORMAL. Usable for audio/video applications near peak rate of the system. ROOT-credentials required.
SCHED_BATCH [ since 2.6.16 in mainline ] SCHED_BATCH was 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_ISO was designed to give users a SCHED_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_IDLEPRIO is similar to SCHED_BATCH, but was explicitly designed to consume only the time the CPU is idle. No interactive boosting is done. If you used SCHED_BATCH in the -ck kernels this is what you want since 2.6.16
Be careful with SCHED_FIFO! You may lock out other processes from the CPU, including your shell.
For SCHED_BATCH you certainly need the a recent 2.6 kernel.
A short overview is given in SCHED_DESIGN and the README contains thorough discussion. The INSTALL file also lists all prerequisites and where you can get patches.
Affinity 0x0 should never be used.
Please contact me via freshmeat.net's "contact author"-feature (http://freshmeat.net/projects/schedtool).