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

NAME

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

SYNOPSIS

9       taskset [options] mask command [arg]...
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       are typically given in hexadecimal.  For example,
31
32       0x00000001
33              is processor #0
34
35       0x00000003
36              is processors #0 and #1
37
38       0xFFFFFFFF
39              is all processors (#0 through #31).
40
41       When taskset returns, it is guaranteed that the given program has  been
42       scheduled to a legal CPU.
43

OPTIONS

45       -a, --all-tasks
46              Set  or retrieve the CPU affinity of all the tasks (threads) for
47              a given PID.
48
49       -p, --pid
50              Operate on an existing PID and do not launch a new task.
51
52       -c, --cpu-list
53              Specify a numerical list of processors  instead  of  a  bitmask.
54              The numbers are separated by commas and may include ranges.  For
55              example: 0,5,7,9-11.
56
57       -h, --help
58              Display usage information and exit.
59
60       -V, --version
61              Display version information and exit.
62

USAGE

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

PERMISSIONS

75       A  user  can change the CPU affinity of a process belonging to the same
76       user.  A user must possess CAP_SYS_NICE to change the CPU affinity of a
77       process  belonging  to  another user.  A user can retrieve the affinity
78       mask of any process.
79

AUTHOR

81       Written by Robert M. Love.
82
84       Copyright © 2004 Robert M. Love
85       This is free software; see the source for copying conditions.  There is
86       NO  warranty;  not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
87       PURPOSE.
88

SEE ALSO

90       chrt(1), nice(1), renice(1), sched_setaffinity(2), sched_getaffinity(2)
91
92       See sched_setscheduler(2) for a description  of  the  Linux  scheduling
93       scheme.
94

AVAILABILITY

96       The  taskset command is part of the util-linux package and is available
97       from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
98
99
100
101util-linux                        April 2003                        TASKSET(1)
Impressum