210 lines
5.5 KiB
HTML
210 lines
5.5 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of TASKSET</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>TASKSET</H1>
|
|
Section: User Commands (1)<BR>Updated: August 2014<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
taskset - set or retrieve a process's CPU affinity
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>taskset</B>
|
|
|
|
[options]
|
|
<I>mask command </I>[<I>argument</I>...]
|
|
|
|
<BR>
|
|
|
|
<B>taskset</B>
|
|
|
|
[options]
|
|
<B>-p</B>
|
|
|
|
[<I>mask</I>] <I>pid</I>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
|
|
<B>taskset</B>
|
|
|
|
is used to set or retrieve the CPU affinity of a running process given its
|
|
<I>pid</I>, or to launch a new <I>command</I> with a given CPU affinity.
|
|
CPU affinity is a
|
|
scheduler property that "bonds" a process to a given set of CPUs on the system.
|
|
The Linux scheduler will honor the given CPU affinity and the process will not
|
|
run on any other CPUs. Note that the Linux scheduler also supports natural
|
|
CPU affinity: the scheduler attempts to keep processes on the same CPU as long
|
|
as practical for performance reasons. Therefore, forcing a specific CPU
|
|
affinity is useful only in certain applications.
|
|
<P>
|
|
The CPU affinity is represented as a bitmask, with the lowest order bit
|
|
corresponding to the first logical CPU and the highest order bit corresponding
|
|
to the last logical CPU. Not all CPUs may exist on a given system but a mask
|
|
may specify more CPUs than are present. A retrieved mask will reflect only the
|
|
bits that correspond to CPUs physically on the system. If an invalid mask is
|
|
given (i.e., one that corresponds to no valid CPUs on the current system) an
|
|
error is returned. The masks may be specified in hexadecimal (with or without
|
|
a leading "0x"), or as a CPU list with the
|
|
<B>--cpu-list</B>
|
|
|
|
option. For example,
|
|
<DL COMPACT><DT id="1"><DD>
|
|
<DL COMPACT>
|
|
<DT id="2"><B>0x00000001</B>
|
|
|
|
<DD>
|
|
is processor #0,
|
|
<DT id="3"><B>0x00000003</B>
|
|
|
|
<DD>
|
|
is processors #0 and #1,
|
|
<DT id="4"><B>0xFFFFFFFF</B>
|
|
|
|
<DD>
|
|
is processors #0 through #31,
|
|
<DT id="5"><B>32</B>
|
|
|
|
<DD>
|
|
is processors #1, #4, and #5,
|
|
<DT id="6"><B>--cpu-list 0-2,6</B>
|
|
|
|
<DD>
|
|
is processors #0, #1, #2, and #6.
|
|
<DT id="7"><B>--cpu-list 0-10:2</B>
|
|
|
|
<DD>
|
|
is processors #0, #2, #4, #6, #8 and #10. The suffix ":N" specifies stride in
|
|
the range, for example 0-10:3 is interpreted as 0,3,6,9 list.
|
|
</DL>
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
When
|
|
<B>taskset</B>
|
|
|
|
returns, it is guaranteed that the given program has been scheduled to a legal
|
|
CPU.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="8"><B>-a</B>, <B>--all-tasks</B>
|
|
|
|
<DD>
|
|
Set or retrieve the CPU affinity of all the tasks (threads) for a given PID.
|
|
<DT id="9"><B>-c</B>, <B>--cpu-list</B>
|
|
|
|
<DD>
|
|
Interpret <I>mask</I> as numerical list of processors instead of a bitmask.
|
|
Numbers are separated by commas and may include ranges. For example:
|
|
<B>0,5,8-11</B>.
|
|
|
|
<DT id="10"><B>-p</B>, <B>--pid</B>
|
|
|
|
<DD>
|
|
Operate on an existing PID and do not launch a new task.
|
|
<DT id="11"><B>-V</B>, <B>--version</B>
|
|
|
|
<DD>
|
|
Display version information and exit.
|
|
<DT id="12"><B>-h</B>, <B>--help</B>
|
|
|
|
<DD>
|
|
Display help text and exit.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>USAGE</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="13">The default behavior is to run a new command with a given affinity mask:<DD>
|
|
<B>taskset</B>
|
|
|
|
<I>mask</I>
|
|
|
|
<I>command </I>[<I>arguments</I>]
|
|
|
|
<DT id="14">You can also retrieve the CPU affinity of an existing task:<DD>
|
|
<B>taskset -p</B>
|
|
|
|
<I>pid</I>
|
|
|
|
<DT id="15">Or set it:<DD>
|
|
<B>taskset -p</B>
|
|
|
|
<I>mask pid</I>
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>PERMISSIONS</H2>
|
|
|
|
A user can change the CPU affinity of a process belonging to the same user.
|
|
A user must possess
|
|
<B>CAP_SYS_NICE</B>
|
|
|
|
to change the CPU affinity of a process belonging to another user.
|
|
A user can retrieve the affinity mask of any process.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+chrt">chrt</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+nice">nice</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+renice">renice</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+sched_getaffinity">sched_getaffinity</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+sched_setaffinity">sched_setaffinity</A></B>(2)
|
|
|
|
<P>
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?7+sched">sched</A></B>(7)
|
|
|
|
for a description of the Linux scheduling scheme.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
Written by Robert M. Love.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
Copyright © 2004 Robert M. Love.
|
|
This is free software; see the source for copying conditions. There is NO
|
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>AVAILABILITY</H2>
|
|
|
|
The taskset command is part of the util-linux package and is available from
|
|
<A HREF="https://www.kernel.org/pub/linux/utils/util-linux/.">https://www.kernel.org/pub/linux/utils/util-linux/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="16"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="17"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="18"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="19"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="20"><A HREF="#lbAF">USAGE</A><DD>
|
|
<DT id="21"><A HREF="#lbAG">PERMISSIONS</A><DD>
|
|
<DT id="22"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
<DT id="23"><A HREF="#lbAI">AUTHOR</A><DD>
|
|
<DT id="24"><A HREF="#lbAJ">COPYRIGHT</A><DD>
|
|
<DT id="25"><A HREF="#lbAK">AVAILABILITY</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:28 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|