public sealed class LinuxProcessorTopologyProcessor counts, performance classes and thread affinity, from the kernel and sysfs.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is the Linux half of what docs/plan/03 deferred out of Vixen.Core.Threading. sched_setaffinity is the call; everything else here is /sys/devices/system/cpu, which is where Linux says what the machine is made of.
pid 0 means the calling thread, not the process. Linux threads are processes with a shared address space, and the affinity calls take a thread id — passing zero means "me", which is the whole of what TrySetAffinity promises. There is no version of this that pins somebody else's thread, and that is deliberate: a job scheduler pins its own workers from inside them.
Two different vendors say "this core is faster" in two different places. ARM big.LITTLE publishes cpu_capacity per processor, a number derived from the device tree. Intel's hybrid parts publish two PMU devices, cpu_core and cpu_atom, each listing the processors it covers. Both are read; a machine with neither is homogeneous as far as anything here can tell, and says so by reporting Unknown rather than by guessing.
Fields and properties (4)
public int AvailableProcessorspublic int PhysicalCoresHow many physical cores there are, or AvailableProcessors where the platform does not distinguish.
public int PerformanceCoresHow many performance cores there are, or 0 where the platform does not say.
public bool SupportsAffinityWhether the kernel let us read this thread's affinity mask.
Methods (4)
public LinuxProcessorTopology()Reads the machine's topology, once.
public ProcessorClass ClassOf(int processor)What kind of core a logical processor sits on.
public bool TrySetAffinity(int processor)Pins the calling thread to one logical processor.
public void ClearAffinity()Undoes a previous TrySetAffinity for the calling thread.
Used by (2)
- LinuxPlatformSupplementVixen.Platform.Linux
- ProcessorTopologyTestsVixen.Platform.Linux.Tests