Skip to main content

CpuSet

Struct CpuSet 

Source
pub struct CpuSet {
Show 13 fields pub id: u32, pub group: u16, pub logical_processor_index: u8, pub core_index: u8, pub last_level_cache_index: u8, pub numa_node_index: u8, pub efficiency_class: u8, pub parked: bool, pub allocated: bool, pub allocated_to_target_process: bool, pub real_time: bool, pub scheduling_class: u8, pub allocation_tag: u64,
}
Expand description

One processor as the CPU-set API describes it.

Field-for-field what the record carries, with the two bitfield unions decoded. Nothing is interpreted and nothing is cross-checked against the relationship walk – see this module’s note on why reconciling here would destroy the only thing a second observer is for.

Fields§

§id: u32

The CPU set’s id, which is what SetThreadSelectedCpuSets takes. Not a processor number, and not interchangeable with one.

§group: u16

The processor group.

§logical_processor_index: u8

The processor’s number within its group.

§core_index: u8

Windows’s index for the owning core.

§last_level_cache_index: u8

Windows’s own last-level-cache grouping: processors sharing a value share an LLC in the scheduler’s view. Deliberately kept even though the relationship walk also reports caches, because this is the OS’s opinion rather than a partition derived from firmware records, and the two are answers to different questions.

§numa_node_index: u8

Windows’s index for the owning NUMA node.

§efficiency_class: u8

The scheduler’s efficiency class. Carried as reported, with no sentinel: a processor absent from this enumeration has no record at all rather than a record holding a stand-in value. Contrast Processor::capacity, which uses 0 for both “class zero” and “not known”.

§parked: bool

The processor is parked, so the scheduler is currently avoiding it.

Measured to carry no information on Windows 11 25H2 – see Self::allocated_to_target_process and D-23 in DESIGN-NOTES.md.

§allocated: bool

The processor is allocated to some process through the CPU-set API.

Measured to carry no information on Windows 11 25H2 – see Self::allocated_to_target_process.

§allocated_to_target_process: bool

The processor is allocated to this process through the CPU-set API.

§This is not “may we run here”, and it is not populated

Two corrections, both established by experiment rather than reasoning (D-23 in DESIGN-NOTES.md).

It does not mean the process may use the processor. It means the CPU set was explicitly allocated through SetProcessDefaultCpuSets or SetThreadSelectedCpuSets, which a process that never called them has not done – so false is the ordinary answer for an ordinary process on every processor it is perfectly free to run on.

And on Windows 11 25H2 (10.0.26200.9168, AMD64) it is not populated at all. Calling SetProcessDefaultCpuSets successfully, and confirming with GetProcessDefaultCpuSets that the allocation stuck, still leaves the whole AllFlags byte reading 0x00 for every processor – under a null handle, the current-process pseudo-handle, and a real OpenProcess handle alike.

So do not branch on this. A reader of false is reading a byte the kernel did not write, not a fact about the machine.

§real_time: bool

The processor is marked real-time.

Measured to carry no information on Windows 11 25H2 – see Self::allocated_to_target_process.

§scheduling_class: u8

The scheduling class, which shares its union with a reserved u32, so confirm its meaning against current SDK documentation before relying on it rather than treating this field as self-describing.

§allocation_tag: u64

The allocation tag.

Trait Implementations§

Source§

impl Clone for CpuSet

Source§

fn clone(&self) -> CpuSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CpuSet

Source§

impl Debug for CpuSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CpuSet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for CpuSet

Source§

impl PartialEq for CpuSet

Source§

fn eq(&self, other: &CpuSet) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CpuSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CpuSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.