Binding


Enumerations

enum  topo_cpubind_policy_t { TOPO_CPUBIND_PROCESS = (1<<0), TOPO_CPUBIND_THREAD = (1<<1), TOPO_CPUBIND_STRICT = (1<<2) }
 Process/Thread binding policy. More...

Functions

int topo_set_cpubind (topo_topology_t topology, const topo_cpuset_t *set, int policy)
 Bind current process or thread on cpus given in cpuset set.
int topo_set_proc_cpubind (topo_topology_t topology, topo_pid_t pid, const topo_cpuset_t *set, int policy)
 Bind a process pid on cpus given in cpuset set.
int topo_set_thread_cpubind (topo_topology_t topology, topo_thread_t tid, const topo_cpuset_t *set, int policy)
 Bind a thread tid on cpus given in cpuset set.

Detailed Description

It is often useful to call topo_cpuset_singlify() first so that a single CPU remains in the set. This way, the process will not even migrate between different CPUs. Some OSes also only support that kind of binding.

Note:
Some OSes do not provide all ways to bind processes, threads, etc and the corresponding binding functions may fail. The most portable version that should be preferred over the others, whenever possible, is
 topo_set_cpubind(topology, set, 0),

as it just binds the current program, assuming it is monothread, or

 topo_set_cpubind(topology, set, TOPO_CPUBIND_THREAD),

which binds the current thread of the current program (which may be multithreaded).

Note:
To unbind, just call the binding function with either a full cpuset or a cpuset equal to the system cpuset.

Enumeration Type Documentation

Process/Thread binding policy.

These flags can be used to refine the binding policy.

The default (0) is to bind the current process, assumed to be mono-thread, in a non-strict way. This is the most portable way to bind as all OSes usually provide it.

Note:
Depending on OSes and implementations, strict binding (i.e. the thread/process will really never be scheduled outside of the cpuset) may not be possible, not be allowed, only used as a hint when no load balancing is needed, etc. If strict binding is required, the strict flag should be set, and the function will fail if strict binding is not possible or allowed.
Enumerator:
TOPO_CPUBIND_PROCESS  Bind all threads of the current multithreaded process. This may not be supported by some OSes (e.g. Linux).
TOPO_CPUBIND_THREAD  Bind current thread of current process.
TOPO_CPUBIND_STRICT  Request for strict binding from the OS Note that strict binding may not be allowed for administrative reasons, and the binding function will fail in that case.


Function Documentation

int topo_set_cpubind ( topo_topology_t  topology,
const topo_cpuset_t set,
int  policy 
)

Bind current process or thread on cpus given in cpuset set.

int topo_set_proc_cpubind ( topo_topology_t  topology,
topo_pid_t  pid,
const topo_cpuset_t set,
int  policy 
)

Bind a process pid on cpus given in cpuset set.

Note:
topo_pid_t is pid_t on unix platforms, and HANDLE on native Windows platforms

TOPO_CPUBIND_THREAD can not be used in policy.

int topo_set_thread_cpubind ( topo_topology_t  topology,
topo_thread_t  tid,
const topo_cpuset_t set,
int  policy 
)

Bind a thread tid on cpus given in cpuset set.

Note:
topo_thread_t is pthread_t on unix platforms, and HANDLE on native Windows platforms

TOPO_CPUBIND_PROCESS can not be used in policy.


Generated on Fri Jul 3 19:00:23 2009 for libtopology by  doxygen 1.5.9