Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sched_getaffinity (nr 204)

Linux Signature

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

Description

Get a thread’s CPU affinity mask.

Current Implementation

Zeroes the user-provided mask buffer, then sets bit 0 (CPU 0 only). Returns cpusetsize (the number of bytes written). ostoo is a single-CPU kernel.

Rust’s standard library calls sched_getaffinity during runtime init to determine available parallelism.

Source: osl/src/syscalls/misc.rssys_sched_getaffinity

Errors

ErrnoCondition
-EINVAL (-22)cpusetsize is 0
-EFAULT (-14)Invalid mask pointer