Struct scheduler::CpuSet
[−]
[src]
pub struct CpuSet { /* fields omitted */ }
Struct representing a bitmask to be used with the affinity functions.
Meant to represent the CPU_*
macros from sched.h
Methods
impl CpuSet
[src]
fn new(num_cpus: usize) -> CpuSet
Create a new CpuSet
with room for num_cpus
CPUs, no cpu will be active.
Equivalent of CPU_ALLOC
fn from_mask<T>(mask: T) -> CpuSet
Create a new CpuSet
from a given mask. For example a u64 or a u8.
fn single(cpu: usize) -> CpuSet
Create a new CpuSet
that with one CPU set as active.
Shorthand for using new
and set
fn set(&mut self, cpu: usize)
Activate a given cpu
on this CpuSet
.
If the given cpu
does not fit in the current CpuSet
, it will be expanded to fit.
Equivalent of CPU_SET
fn clear(&mut self, cpu: usize)
Clear a given cpu
on this CpuSet
.
If the given cpu
does not fit within the current CpuSet
nothing will happen.
Equivalent of CPU_CLR
.
fn is_set(&self, cpu: usize) -> bool
Get if a given CPU is active in this CpuSet
.
If cpu
does not fit in this CpuSet
false will be returned.
Equivalent of CPU_ISSET
.
fn len(&self) -> usize
Get the number of bytes in the mask.
Produces the same results as CPU_ALLOC_SIZE
.
fn mask_ptr(&self) -> *const c_void
Get the raw pointer to the bitmask
Any modification of the CpuSet
after this call might invalidate the pointer.
fn mut_mask_ptr(&mut self) -> *mut c_void
Get a mutable raw pointer to the bitmask.
Any modification of the CpuSet
after this call might invalidate the pointer.
fn as_u64(&self) -> Result<u64, ()>
Represent this CpuSet
as a u64
.
Will return an Err
if the CpuSet
is too large to be written to a u64
fn set_affinity(&self, pid: i32) -> Result<(), ()>
Sets the affinity described by this CpuSet
to a given pid
.
fn get_affinity(pid: i32, num_cpus: usize) -> Result<CpuSet, ()>
Fetch the affinity for a given pid
as a CpuSet
.