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