1TASKSET(1)                    Linux User's Manual                   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       -p, --pid
46              operate on an existing PID and not launch a new task
47
48       -c, --cpu-list
49              specify  a  numerical  list  of processors instead of a bitmask.
50              The list may contain multiple items,  separated  by  comma,  and
51              ranges.  For example, 0,5,7,9-11.
52
53       -h, --help
54              display usage information and exit
55
56       -V, --version
57              output version information and exit
58

USAGE

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

PERMISSIONS

71       A user can change the CPU affinity of a process belonging to  the  same
72       user.  A user must possess CAP_SYS_NICE to change the CPU affinity of a
73       process belonging to another user.  A user can  retrieve  the  affinity
74       mask of any process.
75

AUTHOR

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

SEE ALSO

86       chrt(1), nice(1), renice(1), sched_setaffinity(2), sched_getaffinity(2)
87
88       See  sched_setscheduler(2)  for  a  description of the Linux scheduling
89       scheme.
90

AVAILABILITY

92       The taskset command is part of the util-linux-ng package and is  avail‐
93       able from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
94
95
96
97schedutils                         Apr 2003                         TASKSET(1)
Impressum