]>
Commit | Line | Data |
---|---|---|
48d7b13a KZ |
1 | .\" taskset(1) manpage |
2 | .\" | |
3 | .\" Copyright (C) 2004 Robert Love | |
4 | .\" | |
5 | .\" This is free documentation; you can redistribute it and/or | |
6 | .\" modify it under the terms of the GNU General Public License as | |
7 | .\" published by the Free Software Foundation; either version 2 of | |
8 | .\" the License. | |
9 | .\" | |
10 | .\" The GNU General Public License's references to "object code" | |
11 | .\" and "executables" are to be interpreted as the output of any | |
12 | .\" document formatting or typesetting system, including | |
13 | .\" intermediate and printed output. | |
14 | .\" | |
15 | .\" This manual is distributed in the hope that it will be useful, | |
16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | .\" GNU General Public License for more details. | |
19 | .\" | |
7cebf0bb SK |
20 | .\" You should have received a copy of the GNU General Public License along |
21 | .\" with this program; if not, write to the Free Software Foundation, Inc., | |
22 | .\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
48d7b13a KZ |
23 | .\" |
24 | .\" 2002-05-11 Robert Love <rml@tech9.net> | |
25 | .\" Initial version | |
26 | .\" | |
232dc924 | 27 | .TH TASKSET 1 "April 2003" "util-linux" "User Commands" |
48d7b13a | 28 | .SH NAME |
5ebbcdf9 | 29 | taskset \- retrieve or set a process's CPU affinity |
48d7b13a KZ |
30 | .SH SYNOPSIS |
31 | .B taskset | |
5ebbcdf9 LJ |
32 | .RI [ options ]\ mask |
33 | .IR command\ [ arg ]... | |
34 | .br | |
35 | .B taskset | |
36 | .RI [ options ] | |
37 | .B \-p | |
38 | .RI [ mask ]\ pid | |
48d7b13a KZ |
39 | .SH DESCRIPTION |
40 | .PP | |
232dc924 | 41 | .B taskset |
48d7b13a KZ |
42 | is used to set or retrieve the CPU affinity of a running process given its PID |
43 | or to launch a new COMMAND with a given CPU affinity. CPU affinity is a | |
44 | scheduler property that "bonds" a process to a given set of CPUs on the system. | |
45 | The Linux scheduler will honor the given CPU affinity and the process will not | |
46 | run on any other CPUs. Note that the Linux scheduler also supports natural | |
47 | CPU affinity: the scheduler attempts to keep processes on the same CPU as long | |
48 | as practical for performance reasons. Therefore, forcing a specific CPU | |
49 | affinity is useful only in certain applications. | |
50 | .sp | |
51 | The CPU affinity is represented as a bitmask, with the lowest order bit | |
52 | corresponding to the first logical CPU and the highest order bit corresponding | |
53 | to the last logical CPU. Not all CPUs may exist on a given system but a mask | |
54 | may specify more CPUs than are present. A retrieved mask will reflect only the | |
55 | bits that correspond to CPUs physically on the system. If an invalid mask is | |
56 | given (i.e., one that corresponds to no valid CPUs on the current system) an | |
57 | error is returned. The masks are typically given in hexadecimal. For example, | |
58 | .TP | |
59 | .BR 0x00000001 | |
60 | is processor #0 | |
61 | .TP | |
62 | .BR 0x00000003 | |
63 | is processors #0 and #1 | |
64 | .TP | |
65 | .BR 0xFFFFFFFF | |
64109bba | 66 | is all processors (#0 through #31). |
48d7b13a KZ |
67 | .PP |
68 | When | |
69 | .BR taskset | |
70 | returns, it is guaranteed that the given program has been scheduled to a legal | |
71 | CPU. | |
72 | .SH OPTIONS | |
73 | .TP | |
42708f12 | 74 | .BR \-a ,\ \-\-all-tasks |
64109bba | 75 | Set or retrieve the CPU affinity of all the tasks (threads) for a given PID. |
42708f12 | 76 | .TP |
5ebbcdf9 | 77 | .BR \-p ,\ \-\-pid |
64109bba | 78 | Operate on an existing PID and do not launch a new task. |
48d7b13a | 79 | .TP |
5ebbcdf9 | 80 | .BR \-c ,\ \-\-cpu-list |
64109bba BS |
81 | Specify a numerical list of processors instead of a bitmask. The numbers |
82 | are separated by commas and may include ranges. For example: | |
48d7b13a KZ |
83 | .BR 0,5,7,9-11 . |
84 | .TP | |
5ebbcdf9 | 85 | .BR \-h ,\ \-\-help |
64109bba | 86 | Display usage information and exit. |
48d7b13a | 87 | .TP |
5ebbcdf9 | 88 | .BR \-V ,\ \-\-version |
64109bba | 89 | Display version information and exit. |
48d7b13a KZ |
90 | .SH USAGE |
91 | .TP | |
92 | The default behavior is to run a new command with a given affinity mask: | |
5ebbcdf9 LJ |
93 | .B taskset |
94 | .I mask | |
95 | .IR command\ [ arguments ] | |
48d7b13a KZ |
96 | .TP |
97 | You can also retrieve the CPU affinity of an existing task: | |
5ebbcdf9 LJ |
98 | .B taskset \-p |
99 | .I pid | |
48d7b13a KZ |
100 | .TP |
101 | Or set it: | |
5ebbcdf9 LJ |
102 | .B taskset \-p |
103 | .I mask pid | |
48d7b13a KZ |
104 | .SH PERMISSIONS |
105 | A user must possess | |
5ebbcdf9 | 106 | .B CAP_SYS_NICE |
48d7b13a KZ |
107 | to change the CPU affinity of a process. Any user can retrieve the affinity |
108 | mask. | |
109 | .SH AUTHOR | |
110 | Written by Robert M. Love. | |
48d7b13a KZ |
111 | .SH COPYRIGHT |
112 | Copyright \(co 2004 Robert M. Love | |
113 | .br | |
114 | This is free software; see the source for copying conditions. There is NO | |
115 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
116 | .SH "SEE ALSO" | |
117 | .BR chrt (1), | |
118 | .BR nice (1), | |
119 | .BR renice (1), | |
120 | .BR sched_setaffinity (2), | |
121 | .BR sched_getaffinity (2) | |
122 | .sp | |
123 | See | |
124 | .BR sched_setscheduler (2) | |
125 | for a description of the Linux scheduling scheme. | |
86d62711 | 126 | .SH AVAILABILITY |
601d12fb KZ |
127 | The taskset command is part of the util-linux package and is available from |
128 | ftp://ftp.kernel.org/pub/linux/utils/util-linux/. |