The bindprocessor command
Use the bindprocessor command to bind or unbind the kernel threads of a process to a processor.
# 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.
# bindprocessor 14596 1
# 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.
# 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.
# bindprocessor 7359 1
1730-002: Process 7359 does not match an existing process
# bindprocessor 7358 4
1730-001: Processor 4 is not available