1SCHEDTOOL(8)                System Manager's Manual               SCHEDTOOL(8)
2
3
4

NAME

6       schedtool - query and set CPU scheduling parameters
7
8

SYNOPSIS

10       schedtool
11              [-0|-N] [-1|-F] [-2|-R] [-3|-B] [-4|-I] [-5|-D]
12              [-M policy]
13              [-a affinity]
14              [-p prio]
15              [-n nice_level]
16              [-e command [arg ...]]
17              [-r]
18              [-v]
19              [-h]
20              [LIST OF PIDs]
21
22

DESCRIPTION

24       schedtool  can set all CPU scheduling parameters Linux is capable of or
25       display information for given processes.
26
27       Long-running, non-interactive tasks may  benefit  from  SCHED_BATCH  as
28       timeslices are longer, less system-time is wasted by computing the next
29       runnable process and the caches stay stable.
30
31       Audio/video or other near-realtime applications may run with less skip‐
32       ping  if  set to SCHED_RR.  Use the static priority-switch -p to desig‐
33       nate inter-process-hierarchies.
34
35       schedtool now supports setting the  CPU-affinity  introduced  in  linux
36       2.5.8.
37

OPTIONS

39       -N or -0
40              set all PIDs to SCHED_NORMAL/OTHER
41
42       -F or -1
43              to SCHED_FIFO   root-credentials required
44
45       -R or -2
46              to SCHED_RR     root-credentials required
47
48       -B or -3
49              to SCHED_BATCH
50
51       -I or -4
52              to SCHED_ISO
53
54       -D or -5
55              to SCHED_IDLEPRIO
56
57       -M policy
58              for manual/raw mode; policy is the number of the scheduling pol‐
59              icy (see above for 0-4).  This option is mostly for kernel  guys
60              that want to test their new implementations.
61
62       -p prio
63              specify  static  priority  required for SCHED_FIFO and SCHED_RR.
64              Usually ranged from 1-99.
65
66       -a affinity
67              set the PID's affinity to this bitmask  (hexadecimal);  alterna‐
68              tively, a list mode is supported.
69
70       -n nice_level
71              set the PID's nice level; see nice(2), nice(1).
72
73       -e command [arg ...]
74              execute  command  with  given  scheduling parameters (overwrites
75              schedtool's process image). See EXAMPLES.
76
77       -r     display min and max priority for each policy.
78
79       -v     be verbose.
80
81       -h     help
82
83

EXAMPLES

85       To query the $SHELL's policies:
86
87           #> schedtool $$
88
89       To query some PIDs, namely 1 2 and 3:
90
91           #> schedtool 1 2 3
92
93       To execute mplayer in SCHED_RR with priority 20. The  priority  arg  is
94       needed for both SCHED_RR and SCHED_FIFO.
95
96           #> schedtool -R -p 20 -e mplayer -quiet some_file.avi
97
98       To  set  current  shell  to  SCHED_BATCH,  which all programs the shell
99       starts will inherit:
100
101           #> schedtool -3 $$
102
103       To set all processes with the name 'cpu_hog' to SCHED_BATCH:
104
105           #> schedtool -3 `pidof cpu_hog`
106
107       To set a process' affinity to only the first CPU (CPU0):
108
109           #> schedtool -a 0x1 <PID>
110
111       Using the list mode and affinty of CPU0 and CPU3:
112
113           #> schedtool -a 0,3 <PID>
114
115       A combination of an affinity and a policy-argument is  -  of  course  -
116       always possible.
117
118          #> schedtool -B -a 0x1 <PID>
119
120
121

AFFINITY MASK

123       The  affinity-argument determines on which CPUs a process is allowed to
124       run. It consists of a simple bitmask represented in hexadecimal.   CPU0
125       is  denoted by the least-significant bit, CPU1 by the second least-sig‐
126       nificant and so on, thus giving:
127
128           0x1 -> only run on CPU0
129
130           0x2 -> only run on CPU1
131
132           0x4 -> only run on CPU2
133
134           0x8 -> only run on CPU3 ... and so on.
135
136       Multi-target CPUs may be specified using bitwise OR of the values:
137
138           0x7 -> run on CPUs 0, 1, 2 but NOT on 4
139
140           0x3 -> run only on CPUs 0 and 1
141
142       The default is to run a process on all CPUs, giving a mask of
143
144           0xf for all 4 CPUs
145
146           0xff for all 8 CPUs
147
148

AFFINITY MASK - LIST MODE

150       Alternatively a list mode is supported where you can specify  the  CPUs
151       delimited  by  ",".  The following runs <PID> on CPU0 and CPU1 (equiva‐
152       lent to 0x3):
153
154          #> schedtool -a 0,1 <PID>
155
156

POLICY OVERVIEW

158       SCHED_NORMAL / SCHED_OTHER This is the default policy and for the aver‐
159       age program with some interaction. Does preemption of other processes.
160
161
162       SCHED_FIFO  First-In, First Out Scheduler, used only for real-time con‐
163       traints.  Processes in this class are usually not preempted by  others,
164       they need to free themselves from the CPU via sched_yield() and as such
165       you need special designed applications. Use with extreme  care.   ROOT-
166       credentials required.
167
168
169       SCHED_RR  Round-Robin  Scheduler,  also used for real-time constraints.
170       CPU-time is assigned in an round-robin  fashion  with  a  much  smaller
171       timeslice  than  with  SCHED_NORMAL  and  processes  in  this group are
172       favoured over SCHED_NORMAL. Usable for  audio/video  applications  near
173       peak rate of the system.  ROOT-credentials required.
174
175
176       SCHED_BATCH  [  since 2.6.16 in mainline ] SCHED_BATCH was designed for
177       non-interactive, CPU-bound applications.  It uses longer timeslices (to
178       better exploit the cache), but can be interrupted anytime by other pro‐
179       cesses in other classes to guaratee interaction  of  the  system.  Pro‐
180       cesses in this class are selected last but may result in a considerable
181       speed-up (up to 300%). No interactive boosting is done.
182
183
184       SCHED_ISO [ patch needed ] SCHED_ISO  was  designed  to  give  users  a
185       SCHED_RR-similar  class.  To quote Con Kolivas: "This is a non-expiring
186       scheduler policy designed to guarantee a timeslice within a  reasonable
187       latency  while  preventing  starvation.   Good for gaming, video at the
188       limits of hardware, video capture etc."
189
190
191       SCHED_IDLEPRIO  [  patch  needed  ]  SCHED_IDLEPRIO   is   similar   to
192       SCHED_BATCH,  but was explicitely designed to consume only the time the
193       CPU is idle. No interactive boosting is done.  If you used  SCHED_BATCH
194       in the -ck kernels this is what you want since 2.6.16
195
196

HINTS

198       PID  0  means "current process", in our case, schedtool. May occur when
199       using the -e switch.
200
201       Be careful with SCHED_FIFO! You may lock out other processes  from  the
202       CPU, including your shell.
203
204       For SCHED_BATCH you certainly need the a recent 2.6 kernel.
205
206       A  short  overview  is  given  in  SCHED_DESIGN and the README contains
207       thourough discussion. The INSTALL file also lists all prerequisites and
208       where you can get patches.
209
210       Affinity 0x0 should never be used.
211

SEE ALSO

213       sched_setscheduler(2),    sched_setaffinity(2),    nice(2),    nice(1),
214       renice(3).
215
216

BUGS

218       You need some knowledge about the kernel and scheduling. The author  is
219       a grumpy little elitist.
220
221

AUTHOR

223       Freek
224
225       Please   contact   me   via  freshmeat.net's  "contact  author"-feature
226       (http://freshmeat.net/projects/schedtool).
227
228
229
230                                1 November 2006                   SCHEDTOOL(8)
Impressum