Forrest logo
tool overview
On this page you find all important commands for the CLI tool taskset. If the command you are looking for is missing please ask our AI.

taskset

Taskset is a command line tool in Linux that allows you to set or retrieve the CPU affinity of a process. The CPU affinity determines which CPU or CPUs a process is allowed to execute on. This tool is particularly useful for multi-core or multi-processor systems.

With taskset, you can bind a process to a specific CPU or limit its execution to a specific set of CPUs. You can specify the CPU affinity using either CPU-mask or NUMA memory policy syntax. CPU-mask represents a hexadecimal bitmask that indicates which CPUs the process can run on, while the NUMA memory policy syntax binds the process to a specific NUMA node.

Using taskset, you can easily assign a process to a specific CPU, distribute processes across multiple CPUs for load balancing, or confine processes to specific CPUs to improve cache locality. By optimizing the placement of processes on CPUs, taskset can enhance performance and resource allocation in a system.

This command line tool can be executed by providing a process ID (PID) or by launching a new process with a given CPU affinity. Taskset also offers the option to retrieve the current CPU affinity of a process. It is a powerful utility for managing CPU resources and optimizing process execution on Linux systems.

List of commands for taskset:

  • taskset:tldr:3a9de taskset: Start a new process with affinity for a single CPU.
    $ taskset --cpu-list ${cpu_id} ${command}
    try on your machine
    explain this command
  • taskset:tldr:4cb0e taskset: Get a running process' CPU affinity by PID.
    $ taskset --pid --cpu-list ${pid}
    try on your machine
    explain this command
  • taskset:tldr:b2078 taskset: Set a running process' CPU affinity by PID.
    $ taskset --pid --cpu-list ${cpu_id} ${pid}
    try on your machine
    explain this command
  • taskset:tldr:bfcef taskset: Start a new process with affinity for CPUs 1 through 4.
    $ taskset --cpu-list ${cpu_id_1}-${cpu_id_4}
    try on your machine
    explain this command
  • taskset:tldr:db8b0 taskset: Start a new process with affinity for multiple non-sequential CPUs.
    $ taskset --cpu-list ${cpu_id_1},${cpu_id_2},${cpu_id_3}
    try on your machine
    explain this command
tool overview