bindprocessor Kernel Service

Purpose

Binds or unbinds kernel threads to a processor.

Syntax

#include <sys/processor.h>

int bindprocessor ( What,  Who,  Where)
int What;
int Who;
cpu_t Where;

Parameters

Item Description
What Specifies whether a process or a kernel thread is being bound to a processor. The What parameter can take one of the following values:
BINDPROCESS
A process is being bound to a processor.
BINDTHREAD
A kernel thread is being bound to a processor.
Who Indicates a process or kernel thread identifier, as appropriate for the What parameter, specifying the process or kernel thread which is to be bound to a processor.
Where If the Where parameter is in the range 0-n (where n is the number of online processors in the system), it represents a bind CPU identifier to which the process or kernel thread is to be bound. Otherwise, it represents a processor class, from which a processor will be selected. A value of PROCESSOR_CLASS_ANY unbinds the specified process or kernel thread, which will then be able to run on any processor.

Description

The bindprocessor kernel service binds a single kernel thread, or all kernel threads in a process, to a processor, forcing the bound threads to be scheduled to run on that processor only. It is important to understand that a process itself is not bound, but rather its kernel threads are bound. Once kernel threads are bound, they are always scheduled to run on the chosen processor, unless they are later unbound. When a new thread is created using the thread_create kernel service, it has the same bind properties as its creator.

Programs that use processor bindings should become Dynamic Logical Partitioning (DLPAR) aware. Refer to Dynamic Logical Partitioning in AIX® Version 7.1 General Programming Concepts: Writing and Debugging Programs for more information.

Return Values

On successful completion, the bindprocessor kernel service returns 0. Otherwise, a value of -1 is returned and the error code can be checked by calling the getuerror kernel service.

Error Codes

The bindprocessor kernel service is unsuccessful if one of the following is true:

Item Description
EINVAL The What parameter is invalid, or the Where parameter indicates an invalid processor number or a processor class which is not currently available.
ESRCH The specified process or thread does not exist.
EPERM The caller does not have root user authority, and the Who parameter specifies either a process, or a thread belonging to a process, having a real or effective user ID different from that of the calling process.

Execution Environment

The bindprocessor kernel service can be called from the process environment only.