3 .\" Copyright (C) 2004 Robert Love
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
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.
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.
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, write to the Free
22 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
25 .\" 2002-05-11 Robert Love <rml@tech9.net>
28 .TH TASKSET "1" "Apr 2003" "schedutils" "Linux User's Manual"
30 taskset \- retrieve or set a process's CPU affinity
34 .IR command\ [ arg ]...
43 is used to set or retrieve the CPU affinity of a running process given its PID
44 or to launch a new COMMAND with a given CPU affinity. CPU affinity is a
45 scheduler property that "bonds" a process to a given set of CPUs on the system.
46 The Linux scheduler will honor the given CPU affinity and the process will not
47 run on any other CPUs. Note that the Linux scheduler also supports natural
48 CPU affinity: the scheduler attempts to keep processes on the same CPU as long
49 as practical for performance reasons. Therefore, forcing a specific CPU
50 affinity is useful only in certain applications.
52 The CPU affinity is represented as a bitmask, with the lowest order bit
53 corresponding to the first logical CPU and the highest order bit corresponding
54 to the last logical CPU. Not all CPUs may exist on a given system but a mask
55 may specify more CPUs than are present. A retrieved mask will reflect only the
56 bits that correspond to CPUs physically on the system. If an invalid mask is
57 given (i.e., one that corresponds to no valid CPUs on the current system) an
58 error is returned. The masks are typically given in hexadecimal. For example,
64 is processors #0 and #1
67 is all processors (#0 through #31)
71 returns, it is guaranteed that the given program has been scheduled to a legal
76 operate on an existing PID and not launch a new task
78 .BR \-c ,\ \-\-cpu-list
79 specify a numerical list of processors instead of a bitmask. The list may
80 contain multiple items, separated by comma, and ranges. For example,
84 display usage information and exit
86 .BR \-V ,\ \-\-version
87 output version information and exit
90 The default behavior is to run a new command with a given affinity mask:
93 .IR command\ [ arguments ]
95 You can also retrieve the CPU affinity of an existing task:
105 to change the CPU affinity of a process. Any user can retrieve the affinity
108 Written by Robert M. Love.
110 Copyright \(co 2004 Robert M. Love
112 This is free software; see the source for copying conditions. There is NO
113 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
118 .BR sched_setaffinity (2),
119 .BR sched_getaffinity (2)
122 .BR sched_setscheduler (2)
123 for a description of the Linux scheduling scheme.
125 The taskset command is part of the util-linux-ng package and is available from
126 ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.