pub fn sched_getaffinity(pid: Pid) -> Result<CpuSet>
Expand description
sched_getaffinity
get a thread’s CPU affinity mask
(sched_getaffinity(2)
)
pid
is the thread ID to check.
If pid is zero, then the calling thread is checked.
Returned cpuset
is the set of CPUs on which the thread
is eligible to run.
§Example
Checking if the current thread can run on CPU 0 can be done as follows:
use nix::sched::sched_getaffinity;
use nix::unistd::Pid;
let cpu_set = sched_getaffinity(Pid::from_raw(0)).unwrap();
if cpu_set.is_set(0).unwrap() {
println!("Current thread can run on CPU 0");
}