[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

bindprocessor Subroutine

Purpose

Binds kernel threads to a processor.

Library

Standard C library (libc.a)

Syntax

#include <sys/processor.h>
int bindprocessor (What, Who, Where)
int What;
int Who;
cpu_t Where;

Description

The bindprocessor subroutine 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. 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, it has the same bind properties as its creator. This applies to the initial thread in the new process created by the fork subroutine: the new thread inherits the bind properties of the thread which called fork. When the exec subroutine is called, thread properties are left unchanged.

Parameters

What Specifies whether a process or a 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 thread is being bound to a processor.
Who Indicates a process or thread identifier, as appropriate for the What parameter, specifying the process or thread which is to be bound to a processor.
Where If the Where parameter is a logical processor identifier, it specifies the processor to which the process or thread is to be bound. A value of PROCESSOR_CLASS_ANY unbinds the specified process or thread, which will then be able to run on any processor.

The sysconf subroutine can be used to retrieve information about the number of processors in the system.

Return Values

On successful completion, the bindprocessor subroutine returns 0. Otherwise, a value of -1 is returned, and the errno global variable is set to indicate the error.

Error Codes

The bindprocessor subroutine is unsuccessful if one of the following is true:

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.

Implementation Specifics

The bindprocessor subroutine is part of the Base Operating System (BOS) Runtime.

Related Information

The bindprocessor command.

The exec subroutine, fork subroutine, sysconf subroutine, thread_self subroutine.

Controlling Processor Use in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]