NCBI C++ ToolKit
Static Public Member Functions | List of all members
CSystemInfo Class Reference

Search Toolkit Book for CSystemInfo

CSystemInfo –. More...

#include <corelib/ncbi_system.hpp>

Static Public Member Functions

static string GetUserName (void)
 Get actual user name for the current process. More...
 
static unsigned int GetCpuCount (void)
 Return number of active CPUs/cores (never less than 1). More...
 
static unsigned int GetCpuCountAllowed (void)
 Return number of allowed to use CPUs/cores for the current thread. More...
 
static double GetUptime (void)
 Get system uptime in seconds. More...
 
static Uint8 GetTotalPhysicalMemorySize (void)
 Return the amount of actual/total physical memory, in bytes. More...
 
static Uint8 GetAvailPhysicalMemorySize (void)
 Return the amount of physical memory currently available on the system ("free"), in bytes. More...
 
static unsigned long GetVirtualMemoryPageSize (void)
 Return virtual memory page size. More...
 
static unsigned long GetVirtualMemoryAllocationGranularity (void)
 Return size of an allocation unit (usually it is a multiple of page size). More...
 
static clock_t GetClockTicksPerSecond (void)
 Get number of (statistics) clock ticks per second. More...
 

Detailed Description

CSystemInfo –.

Return various system information. All methods work on UNIX and Windows, unless otherwise stated.

Definition at line 409 of file ncbi_system.hpp.

Member Function Documentation

◆ GetAvailPhysicalMemorySize()

Uint8 CSystemInfo::GetAvailPhysicalMemorySize ( void  )
static

Return the amount of physical memory currently available on the system ("free"), in bytes.

Returns
0, if cannot determine it on current platform, or on error.

Definition at line 906 of file ncbi_system.cpp.

References CNcbiError::eNotSupported, GetVirtualMemoryPageSize(), len, NULL, and CNcbiError::Set().

◆ GetClockTicksPerSecond()

clock_t CSystemInfo::GetClockTicksPerSecond ( void  )
static

Get number of (statistics) clock ticks per second.

Many OS system information values use it as a size unit.

Returns
0, if cannot determine it on current platform, or on error.

Definition at line 954 of file ncbi_system.cpp.

References CLOCKS_PER_SEC, CNcbiError::eNotSupported, CNcbiError::Set(), CNcbiError::SetFromErrno(), t, and value.

Referenced by CCurrentProcess::GetTimes().

◆ GetCpuCount()

unsigned int CSystemInfo::GetCpuCount ( void  )
static

◆ GetCpuCountAllowed()

unsigned int CSystemInfo::GetCpuCountAllowed ( void  )
static

Return number of allowed to use CPUs/cores for the current thread.

Returns 0 if unable to get this information on the current OS, or error occurs.

Definition at line 702 of file ncbi_system.cpp.

References GetCpuCount(), n, and NULL.

◆ GetTotalPhysicalMemorySize()

Uint8 CSystemInfo::GetTotalPhysicalMemorySize ( void  )
static

Return the amount of actual/total physical memory, in bytes.

On some platforms it can be less then installed physical memory, and represent a total usable RAM (physical RAM minus reserved and the kernel).

Returns
0, if cannot determine it on current platform, or if an error occurs.

Definition at line 839 of file ncbi_system.cpp.

References CNcbiError::eNotSupported, GetVirtualMemoryPageSize(), len, NULL, CNcbiError::Set(), and value.

Referenced by CAlignSort::CAlignSort(), CVDBBlastUtil::GetMaxNumCSRAThread(), GetPhysicalMemorySize(), CPubseqGatewayApp::OnInfo(), CNcbiApplicationAPI::x_HonorStandardSettings(), and CNetScheduleHandler::x_ProcessHealth().

◆ GetUptime()

double CSystemInfo::GetUptime ( void  )
static

Get system uptime in seconds.

Returns
Seconds since last boot, or negative number if cannot determine it on current platform, or on error.

Definition at line 749 of file ncbi_system.cpp.

References CNcbiError::eNotSupported, kMicroSecondsPerSecond, kMilliSecondsPerSecond, kNanoSecondsPerSecond, len, NULL, and CNcbiError::Set().

◆ GetUserName()

string CSystemInfo::GetUserName ( void  )
static

Get actual user name for the current process.

Note
Doesn't use environment as it can be changed.
Returns
Process owner user name, or empty string if it cannot be determined.

Definition at line 646 of file ncbi_system.cpp.

References CWinSecurity::GetUserName(), CUnixFeature::GetUserNameByUID(), and string.

Referenced by GetProcessUserName(), CDiagContext_Extra::PrintNcbiAppInfoOnStart(), s_GetCubbyUserName(), CPubseqReader::x_ConnectAtSlot(), and CId2FetchApp::x_InitPubSeqConnection().

◆ GetVirtualMemoryAllocationGranularity()

unsigned long CSystemInfo::GetVirtualMemoryAllocationGranularity ( void  )
static

Return size of an allocation unit (usually it is a multiple of page size).

Returns
0, if cannot determine it on current platform, or on error.

Definition at line 821 of file ncbi_system.cpp.

References GetVirtualMemoryPageSize(), si, and value.

Referenced by CMemoryFileSegment::CMemoryFileSegment(), GetVirtualMemoryAllocationGranularity(), and CJson_Document::ReadBuffered().

◆ GetVirtualMemoryPageSize()

unsigned long CSystemInfo::GetVirtualMemoryPageSize ( void  )
static

Return virtual memory page size.

Returns
0, if cannot determine it on current platform, or on error.

Definition at line 785 of file ncbi_system.cpp.

References CNcbiError::eNotSupported, NCBI_OS_UNIX, CNcbiError::Set(), CNcbiError::SetFromErrno(), si, and value.

Referenced by GetAvailPhysicalMemorySize(), GetMemoryUsage(), GetTotalPhysicalMemorySize(), GetVirtualMemoryAllocationGranularity(), GetVirtualMemoryPageSize(), and CTar::x_Init().


The documentation for this class was generated from the following files:
Modified on Wed Feb 21 09:55:33 2024 by modify_doxy.py rev. 669887