sched_getaffinity

Name

sched_getaffinity -- retrieve the affinity mask of a process

Synopsis

#include <sched.h>

int sched_getaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t * mask);

Description

sched_getaffinity() shall retrieve the affinity mask of a process.

The parameter pid specifies the ID for the process. If pid is 0, then the calling process is specified instead.

The parameter cpusetsize specifies the length of the data pointed to by mask, in bytes. Normally, this parameter is specified as sizeof(cpu_set_t).

Return Value

On success, sched_getaffinity() shall return 0, and the structure pointed to by mask shall contain the affinity mask of the specified process.

On failure, sched_getaffinity() shall return -1 and set errno as follows.

Errors

EFAULT 

Bad address.

EINVAL 

mask does not specify any processors that exist in the system, or cpusetsize is smaller than the kernel's affinity mask.

ESRCH 

The specified process could not be found.

See Also

sched_setscheduler(), sched_setaffinity().