Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
lcpu.cpp File Reference
#include "precompiled.h"
#include "lib/sysdep/os_cpu.h"
#include "lib/alignment.h"
#include "lib/bits.h"
#include "lib/config2.h"
#include "lib/module_init.h"
Include dependency graph for lcpu.cpp:

Functions

size_t os_cpu_NumProcessors ()
 
uintptr_t os_cpu_ProcessorMask ()
 
size_t os_cpu_PageSize ()
 
size_t os_cpu_LargePageSize ()
 
size_t os_cpu_QueryMemorySize ()
 
size_t os_cpu_MemoryAvailable ()
 
static bool IsMaxCpusSufficient ()
 
static Status DetectMaxCpus ()
 
uintptr_t os_cpu_SetThreadAffinityMask (uintptr_t processorMask)
 restrict the current thread to a set of processors. More...
 
Status os_cpu_CallByEachCPU (OsCpuCallback cb, uintptr_t cbData)
 execute the specified function once on each processor. More...
 

Variables

static size_t maxCpus
 

Function Documentation

◆ DetectMaxCpus()

static Status DetectMaxCpus ( )
static

◆ IsMaxCpusSufficient()

static bool IsMaxCpusSufficient ( )
static

◆ os_cpu_CallByEachCPU()

Status os_cpu_CallByEachCPU ( OsCpuCallback  cb,
uintptr_t  cbData 
)

execute the specified function once on each processor.

this proceeds serially (the callback is never reentered) in increasing order of processor ID. fails if process affinity prevents running on all processors.

◆ os_cpu_LargePageSize()

size_t os_cpu_LargePageSize ( )
Returns
the size [bytes] of a large MMU page (4 MiB on most IA-32 systems) or zero if they are not supported.

◆ os_cpu_MemoryAvailable()

size_t os_cpu_MemoryAvailable ( )
Returns
the current amount [MB] of available memory.

◆ os_cpu_NumProcessors()

size_t os_cpu_NumProcessors ( )
Returns
the number of processors available to this process.

note: this function is necessary because POSIX sysconf _SC_NPROCESSORS_CONF is not suppored on MacOSX, else we would use that.

◆ os_cpu_PageSize()

size_t os_cpu_PageSize ( )
Returns
the size [bytes] of a MMU page (4096 on most IA-32 systems)

◆ os_cpu_ProcessorMask()

uintptr_t os_cpu_ProcessorMask ( )
Returns
bit mask of processors that exist and are available to this process. its population count is by definition equal to os_cpu_NumProcessors().

◆ os_cpu_QueryMemorySize()

size_t os_cpu_QueryMemorySize ( )
Returns
the size [MB] of physical memory as reported by the OS; no caching/validation is performed.

◆ os_cpu_SetThreadAffinityMask()

uintptr_t os_cpu_SetThreadAffinityMask ( uintptr_t  processorMask)

restrict the current thread to a set of processors.

Parameters
processorMaska bit mask of acceptable processors (bit index i corresponds to processor i)
Returns
the previous mask

Variable Documentation

◆ maxCpus

size_t maxCpus
static