Rate This Document
Findability
Accuracy
Completeness
Readability

HTL_thread_setaffinity_np

Sets thread affinity.

Interface Definition

int HTL_thread_setaffinity_np(HTL_thread_t *thread, size_t cpu_set_size, const cpu_set_t *cpuset);

Description

HTL_thread_setaffinity_np() is used to set the CPU affinity of a thread and bind the thread to a specific CPU set. cpu_set_size specifies the CPU set size (in bytes).

Currently, the target CPU set must be within the CPU set range of the current executor. If the target CPU set of the thread is the same as that of the associated executor, HTL_THREAD_ERR_MIGRATION_TARGET is returned.

Parameters

Parameter

Type

Description

Input/Output

thread

HTL_thread_t *

Address of the handle to the thread.

Input

cpu_set_size

size_t

Size of the CPU set.

Input

cpuset

cpu_set_t *

CPU set.

Input

Return Value

  • HTL_THREAD_SUCCESS: success.
  • Other values: failure. For details, see the error code descriptions.

Example

1
    int status = HTL_thread_setaffinity_np(thread, sizeof(cpu_set_t), &cpu_set);