Skip to main content

cpu_affinity

Function cpu_affinity 

Source
pub fn cpu_affinity(thread_id: Option<pid_t>) -> Result<Vec<CpuId>>
Expand description

Get the CPU affinity mask for a thread.

Returns a sorted vector of CPU IDs that the thread is allowed to run on.

§Arguments

  • thread_id - Thread ID to query. None means the calling thread.

§Examples

let cpus = cpu_affinity(None)?;
println!("Thread can run on CPUs: {:?}", cpus);

§Errors

Returns io::Error if the system call fails.