Controlling processor use

This section describes how to control the use of processors on the multiprocessor system.

On a multiprocessor system, the use of processors can be controlled in the following way:
  • A user can force a process or kernel threads to run on a specific processor.

Binding processes and kernel threads

Users may force their processes to run on a given processor; this action is called binding. A system administrator may bind any process. From the command line, binding is controlled with the bindprocessor command.

The process itself is not bound, but rather its kernel threads are bound. After kernel threads are bound, they are always scheduled to run on the chosen processor, unless they are later unbound. When a new kernel thread is created, it has the same bind properties as its creator.

This situation applies to the initial thread in the new process created by the fork subroutine; the new thread inherits the bind properties of the thread that called the fork subroutine. When the exec subroutine is called, bind properties are left unchanged. After a process is bound to a processor, if no other binding or unbinding action is performed, all child processes will be bound to the same processor.

It is only possible to bind processes to enabled processors using logical processor numbers. To list available logical processor numbers, use the bindprocessor -q command. For a system with four enabled processors, this command produces output similar to the following:
The available processors are: 0 1 2 3

Binding may also be controlled within a program using the bindprocessor subroutine, which allows the programmer to bind a single kernel thread or all kernel threads in a process. The programmer can also unbind either a single kernel thread or all kernel threads in a process.