Pyrogenesis  trunk
Classes | Namespaces | Typedefs | Functions | Variables
os_cpu.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  os_cpu_ScopedSetThreadAffinityMask
 

Namespaces

 ERR
 

Introduction


 

Typedefs

typedef void(* OsCpuCallback) (size_t processor, uintptr_t cbData)
 called by os_cpu_CallByEachCPU. More...
 

Functions

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

Variables

const Status ERR::OS_CPU_RESTRICTED_AFFINITY = -130100
 
static const size_t os_cpu_MaxProcessors = sizeof(uintptr_t)*CHAR_BIT
 maximum number of processors supported by the OS (determined by the number of bits in an affinity mask) More...
 

Typedef Documentation

typedef void(* OsCpuCallback) (size_t processor, uintptr_t cbData)

called by os_cpu_CallByEachCPU.

Parameters
processorID of processor running the current thread for the duration of this function.
cbDatauser-specified data passed through os_cpu_CallByEachCPU.

Function Documentation

LIB_API 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.

LIB_API double os_cpu_ClockFrequency ( )
Returns
a rough estimate of the CPU clock frequency. this is usually accurate to a few MHz and is faster than measurement loops.
LIB_API 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.
LIB_API size_t os_cpu_MemoryAvailable ( )
Returns
the current amount [MB] of available memory.
LIB_API size_t os_cpu_MemorySize ( )
Returns
the size [MB] of physical memory; caches the result of os_cpu_QueryMemorySize and overrides it with a more exact value if SMBIOS information is available.
LIB_API 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.

LIB_API size_t os_cpu_PageSize ( )
Returns
the size [bytes] of a MMU page (4096 on most IA-32 systems)
LIB_API 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().
LIB_API size_t os_cpu_QueryMemorySize ( )
Returns
the size [MB] of physical memory as reported by the OS; no caching/validation is performed.
LIB_API 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

const size_t os_cpu_MaxProcessors = sizeof(uintptr_t)*CHAR_BIT
static

maximum number of processors supported by the OS (determined by the number of bits in an affinity mask)