.\" Text automatically generated by txt2man-1.4.5 .TH "SCHEDTOOL" 8 "1 November 2006" "" "System Manager's Manual" .SH "NAME" \fBschedtool \fP\- query and set CPU scheduling parameters .SH "SYNOPSIS" .nf .fam C .TP \fBschedtool\fP [\fB\-0\fP|\fB\-N\fP] [\fB\-1\fP|\fB\-F\fP] [\fB\-2\fP|\fB\-R\fP] [\fB\-3\fP|\fB\-B\fP] [\fB\-4\fP|\fB\-I\fP] [\fB\-5\fP|\fB\-D\fP] [\fB\-M\fP \fIpolicy\fP] [\fB\-a\fP \fIaffinity\fP] [\fB\-p\fP \fIprio\fP] [\fB\-n\fP \fInice_level\fP] [\fB\-e\fP \fIcommand [arg ...]\fP] [\fB\-r\fP] [\fB\-v\fP] [\fB\-h\fP] [LIST OF \fIPIDs\fP] .fam T .fi .SH "DESCRIPTION" \fBschedtool\fP can set all CPU scheduling parameters Linux is capable of or display information for given processes. .P 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. .P Audio/video or other near\-realtime applications may run with less skipping if set to SCHED_RR. Use the static priority\-switch \fB\-p\fP to designate inter\-process\-hierarchies. .TP \fBschedtool\fP now supports setting the CPU\-affinity introduced in linux 2.5.8. .SH "OPTIONS" .TP .B \fB\-N\fP or \fB\-0\fP set all \fIPIDs\fP to SCHED_NORMAL/OTHER .TP .B \fB\-F\fP or \fB\-1\fP to SCHED_FIFO root\-credentials required .TP .B \fB\-R\fP or \fB\-2\fP to SCHED_RR root\-credentials required .TP .B \fB\-B\fP or \fB\-3\fP to SCHED_BATCH .TP .B \fB\-I\fP or \fB\-4\fP to SCHED_ISO .TP .B \fB\-D\fP or \fB\-5\fP to SCHED_IDLEPRIO .TP .B \fB\-M\fP \fIpolicy\fP for manual/raw mode; policy is the number of the scheduling policy (see above for 0-4). This option is mostly for kernel guys that want to test their new implementations. .TP .B \fB\-p\fP \fIprio\fP specify static priority \fBrequired\fP for SCHED_FIFO and SCHED_RR. Usually ranged from 1\-99. .TP .B \fB\-a\fP \fIaffinity\fP set the PID's \fIaffinity\fP to this bitmask (hexadecimal); alternatively, a list mode is supported. .TP .B \fB\-n\fP \fInice_level\fP set the PID's nice level; see \fBnice(2), nice(1)\fP. .TP .B \fB\-e\fP \fIcommand [arg ...]\fP execute \fIcommand\fP with given scheduling parameters (overwrites schedtool's process image). See EXAMPLES. .TP .B \fB\-r\fP display min and max priority for each policy. .TP .B \fB\-v\fP be verbose. .TP .B \fB\-h\fP help .SH "EXAMPLES" To query the $SHELL's policies: .PP .nf .fam C #> schedtool $$ To query some \fIPIDs\fP, namely 1 2 and 3: .PP .nf .fam C #> schedtool 1 2 3 .fam T .fi To \fBexecute\fP mplayer in \fBSCHED_RR\fP with priority 20. The priority arg is needed for both SCHED_RR and SCHED_FIFO. .PP .nf .fam C #> schedtool \-R \-p 20 \-e mplayer -quiet some_file.avi .fam T .fi To set current shell to \fBSCHED_BATCH\fP, which all programs the shell starts will inherit: .PP .nf .fam C #> schedtool \-3 $$ .fam T .fi To set all processes with the name 'cpu_hog' to SCHED_BATCH: .PP .nf .fam C #> schedtool \-3 `pidof cpu_hog` .fam T .fi To set a process' \fIaffinity\fP to only the first CPU (CPU0): .PP .nf .fam C #> schedtool \-a 0x1 .fam T Using the list mode and affinty of CPU0 and CPU3: .PP .nf .fam C #> schedtool -a 0,3 .fam T .fi A combination of an \fIaffinity\fP and a \fIpolicy\fP\-argument is \- of course \- always possible. .PP .nf .fam C #> schedtool \-B \-a 0x1 .fam T .fi .SH "AFFINITY MASK" The \fIaffinity\fP\-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: .PP \fB0x1\fP \-> only run on CPU0 .PP \fB0x2\fP \-> only run on CPU1 .PP \fB0x4\fP \-> only run on CPU2 .PP \fB0x8\fP \-> only run on CPU3 ... and so on. .PP Multi\-target CPUs may be specified using bitwise OR of the values: .PP \fB0x7\fP \-> run on CPUs 0, 1, 2 but \fBNOT\fP on 4 .PP \fB0x3\fP \-> run only on CPUs 0 and 1 .PP The default is to run a process on all CPUs, giving a mask of .PP \fB0xf\fP for all 4 CPUs .PP \fB0xff\fP for all 8 CPUs .SH "AFFINITY MASK - LIST MODE" Alternatively a list mode is supported where you can specify the CPUs delimited by ",". The following runs on CPU0 and CPU1 (equivalent to \fB0x3\fP): .PP .nf .fam C #> schedtool \-a \fB0,1\fP .SH "POLICY OVERVIEW" \fBSCHED_NORMAL / SCHED_OTHER\fP This is the default policy and for the average program with some interaction. Does preemption of other processes. .PP \fBSCHED_FIFO\fP 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. \fBUse with extreme care.\fP \fBROOT-credentials required.\fP .PP \fBSCHED_RR\fP 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. \fBROOT-credentials required.\fP .PP \fBSCHED_BATCH\fP [ 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. .PP \fBSCHED_ISO\fP [ 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." .PP \fBSCHED_IDLEPRIO\fP [ 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 .SH "HINTS" PID 0 means "current process", in our case, schedtool. May occur when using the \-e switch. .PP Be careful with SCHED_FIFO! You may lock out other processes from the CPU, including your shell. .PP For SCHED_BATCH you \fIcertainly\fP need the a recent 2.6 kernel. .PP A short overview is given in SCHED_DESIGN and the \fBREADME\fP contains thorough discussion. The \fBINSTALL\fP file also lists all prerequisites and where you can get patches. .PP Affinity 0x0 should never be used. .SH "SEE ALSO" \fBsched_setscheduler\fP(2), \fBsched_setaffinity\fP(2), \fBnice\fP(2), \fBnice\fP(1), \fBrenice\fP(3). .SH "BUGS" You need some knowledge about the kernel and scheduling. The author is a grumpy little elitist. .SH "AUTHOR" Freek .P Please contact me via freshmeat.net's "contact author"\-feature (http://freshmeat.net/projects/schedtool).