-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathschedtool.8
250 lines (228 loc) · 6.99 KB
/
schedtool.8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
.\" 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 <PID>
.fam T
Using the list mode and affinty of CPU0 and CPU3:
.PP
.nf
.fam C
#> schedtool -a 0,3 <PID>
.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 <PID>
.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 <PID> on CPU0 and CPU1 (equivalent to \fB0x3\fP):
.PP
.nf
.fam C
#> schedtool \-a \fB0,1\fP <PID>
.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 contraints.
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 explicitely 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 thourough 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).