The bindprocessor command

Use the bindprocessor command to bind or unbind the kernel threads of a process to a processor.

Root authority is necessary to bind or unbind threads in processes that you do not own.
Note: The bindprocessor command is meant for multiprocessor systems. Although it will also work on uniprocessor systems, binding has no effect on such systems.
To query the available processors, run the following:
# bindprocessor -q
The available processors are:  0 1 2 3

The output shows the logical processor numbers for the available processors, which are used with the bindprocessor command as will be seen.

To bind a process whose PID is 14596 to processor 1, run the following:
# bindprocessor 14596 1
No return message is given if the command was successful. To verify if a process is bound or unbound to a processor, use the ps -mo THREAD command as explained in Using the ps command:
# ps -mo THREAD
USER   PID  PPID    TID ST  CP PRI SC    WCHAN        F     TT BND COMMAND
root  3292  7130      - A    1  60  1        -   240001  pts/0   - -ksh
   -     -     -  14309 S    1  60  1        -      400      -   - -
root 14596  3292      - A   73 100  1        -   200001  pts/0   1 /tmp/cpubound
   -     -     -  15629 R   73 100  1        -        0      -   1 -
root 15606  3292      - A   74 101  1        -   200001  pts/0   - /tmp/cpubound
   -     -     -  16895 R   74 101  1        -        0      -   - -
root 16634  3292      - A   73 100  1        -   200001  pts/0   - /tmp/cpubound
   -     -     -  15107 R   73 100  1        -        0      -   - -
root 18048  3292      - A   14  67  1        -   200001  pts/0   - ps -mo THREAD
   -     -     -  17801 R   14  67  1        -        0      -   - -

The BND column shows the number of the processor that the process is bound to or a dash (-) if the process is not bound at all.

To unbind a process whose PID is 14596, use the following command:
# bindprocessor -u 14596
# ps -mo THREAD
USER   PID  PPID    TID ST  CP PRI SC    WCHAN        F     TT BND COMMAND
root  3292  7130      - A    2  61  1        -   240001  pts/0   - -ksh
   -     -     -  14309 S    2  61  1        -      400      -   - -
root 14596  3292      - A  120 124  1        -   200001  pts/0   - /tmp/cpubound
   -     -     -  15629 R  120 124  1        -        0      -   - -
root 15606  3292      - A  120 124  1        -   200001  pts/0   - /tmp/cpubound
   -     -     -  16895 R  120 124  1        -        0      -   - -
root 16634  3292      - A  120 124  0        -   200001  pts/0   - /tmp/cpubound
   -     -     -  15107 R  120 124  0        -        0      -   - -
root 18052  3292      - A   12  66  1        -   200001  pts/0   - ps -mo THREAD
   -     -     -  17805 R   12  66  1        -        0      -   - -

When the bindprocessor command is used on a process, all of its threads will then be bound to one processor and unbound from their former processor. Unbinding the process will also unbind all its threads. You cannot bind or unbind an individual thread using the bindprocessor command.

However, within a program, you can use the bindprocessor() function call to bind individual threads. If the bindprocessor() function is used within a piece of code to bind threads to processors, the threads remain with these processors and cannot be unbound. If the bindprocessor command is used on that process, all of its threads will then be bound to one processor and unbound from their respective former processors. An unbinding of the whole process will also unbind all the threads.

A process cannot be bound until it is started; that is, it must exist in order to be bound. When a process does not exist, the following error displays:
# bindprocessor 7359 1
1730-002: Process 7359 does not match an existing process
When a processor does not exist, the following error displays:
# bindprocessor 7358 4
1730-001: Processor 4 is not available
Note: Do not use the bindprocessor command on the wait processes kproc.