[−][src]Function nix::sched::sched_setaffinity
pub fn sched_setaffinity(pid: Pid, cpuset: &CpuSet) -> Result<()>
sched_setaffinity
set a thread's CPU affinity mask
(sched_setaffinity(2)
)
pid
is the thread ID to update.
If pid is zero, then the calling thread is updated.
The cpuset
argument specifies the set of CPUs on which the thread
will be eligible to run.
Example
Binding the current thread to CPU 0 can be done as follows:
use nix::sched::{CpuSet, sched_setaffinity}; use nix::unistd::Pid; let mut cpu_set = CpuSet::new(); cpu_set.set(0); sched_setaffinity(Pid::from_raw(0), &cpu_set);