1TASKSET(1)                       User Commands                      TASKSET(1)
2
3
4

NAME

6       taskset - set or retrieve a process's CPU affinity
7

SYNOPSIS

9       taskset [options] mask command [argument...]
10       taskset [options] -p [mask] pid
11

DESCRIPTION

13       taskset  is  used  to  set  or  retrieve  the CPU affinity of a running
14       process given its pid, or to launch a new  command  with  a  given  CPU
15       affinity.   CPU affinity is a scheduler property that "bonds" a process
16       to a given set of CPUs on the system.  The Linux scheduler  will  honor
17       the  given CPU affinity and the process will not run on any other CPUs.
18       Note that the Linux scheduler also supports natural CPU  affinity:  the
19       scheduler attempts to keep processes on the same CPU as long as practi‐
20       cal for performance reasons.  Therefore, forcing a specific CPU  affin‐
21       ity is useful only in certain applications.
22
23       The CPU affinity is represented as a bitmask, with the lowest order bit
24       corresponding to the first logical CPU and the highest order bit corre‐
25       sponding  to  the  last logical CPU.  Not all CPUs may exist on a given
26       system but a mask may specify more CPUs than are present.  A  retrieved
27       mask  will  reflect only the bits that correspond to CPUs physically on
28       the system.  If an invalid mask is given (i.e., one that corresponds to
29       no  valid  CPUs on the current system) an error is returned.  The masks
30       may be specified in hexadecimal (with or without a leading "0x"), or as
31       a CPU list with the --cpu-list option.  For example,
32
33           0x00000001  is processor #0,
34
35           0x00000003  is processors #0 and #1,
36
37           0xFFFFFFFF  is processors #0 through #31,
38
39           32          is processors #1, #4, and #5,
40
41           --cpu-list 0-2,6
42                       is processors #0, #1, #2, and #6.
43
44       When  taskset returns, it is guaranteed that the given program has been
45       scheduled to a legal CPU.
46

OPTIONS

48       -a, --all-tasks
49              Set or retrieve the CPU affinity of all the tasks (threads)  for
50              a given PID.
51
52       -c, --cpu-list
53              Interpret mask as numerical list of processors instead of a bit‐
54              mask.  Numbers are separated by commas and may  include  ranges.
55              For example: 0,5,8-11.
56
57       -p, --pid
58              Operate on an existing PID and do not launch a new task.
59
60       -V, --version
61              Display version information and exit.
62
63       -h, --help
64              Display help text and exit.
65

USAGE

67       The  default  behavior  is  to  run a new command with a given affinity
68       mask:
69              taskset mask command [arguments]
70
71       You can also retrieve the CPU affinity of an existing task:
72              taskset -p pid
73
74       Or set it:
75              taskset -p mask pid
76

PERMISSIONS

78       A user can change the CPU affinity of a process belonging to  the  same
79       user.  A user must possess CAP_SYS_NICE to change the CPU affinity of a
80       process belonging to another user.  A user can  retrieve  the  affinity
81       mask of any process.
82

SEE ALSO

84       chrt(1), nice(1), renice(1), sched_getaffinity(2), sched_setaffinity(2)
85
86       See sched(7) for a description of the Linux scheduling scheme.
87

AUTHOR

89       Written by Robert M. Love.
90
92       Copyright © 2004 Robert M. Love.  This is free software; see the source
93       for copying conditions.  There  is  NO  warranty;  not  even  for  MER‐
94       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
95

AVAILABILITY

97       The  taskset command is part of the util-linux package and is available
98       from https://www.kernel.org/pub/linux/utils/util-linux/.
99
100
101
102util-linux                        August 2014                       TASKSET(1)
Impressum