src/corelib/ncbi_system.cpp File Reference

#include <ncbi_pch.hpp>
#include <corelib/ncbimtx.hpp>
#include <corelib/ncbi_system.hpp>
#include <corelib/ncbi_safe_static.hpp>
#include <corelib/error_codes.hpp>

Include dependency graph for ncbi_system.cpp:

Go to the source code of this file.

Defines

#define NCBI_USE_ERRCODE_X   Corelib_System

Functions

static void s_ExitHandler (void)
static void s_SignalHandler (int sig)
bool SetHeapLimit (size_t max_heap_size, TLimitsPrintHandler handler, TLimitsPrintParameter parameter)
 [UNIX only] Set memory limit.
bool SetCpuTimeLimit (size_t max_cpu_time, TLimitsPrintHandler handler, TLimitsPrintParameter parameter, size_t terminate_time)
 [UNIX only] Set CPU usage limit.
unsigned int GetCpuCount (void)
 [UNIX & Windows] Return number of active CPUs (never less than 1).
unsigned long GetVirtualMemoryPageSize (void)
 [UNIX & Windows] Return granularity with which virtual memory is allocated.
Uint8 GetPhysicalMemorySize (void)
 [UNIX & Windows] Return the amount of physical memory available on the machine.
bool GetMemoryUsage (size_t *total, size_t *resident, size_t *shared)
 [UNIX & Windows] Return current memory usage, in bytes.
void SleepMicroSec (unsigned long mc_sec, EInterruptOnSignal onsignal)
void SleepMilliSec (unsigned long ml_sec, EInterruptOnSignal onsignal)
void SleepSec (unsigned long sec, EInterruptOnSignal onsignal)
 Sleep.
void SuppressSystemMessageBox (TSuppressSystemMessageBox mode)
 Suppress popup messages on execution errors.
void DisableSuppressSystemMessageBox (void)
 Prevent run of SuppressSystemMessageBox().


Define Documentation

#define NCBI_USE_ERRCODE_X   Corelib_System
 

Definition at line 39 of file ncbi_system.cpp.


Function Documentation

void DisableSuppressSystemMessageBox  ) 
 

Prevent run of SuppressSystemMessageBox().

NOTE: MS Windows-specific. If this function is called, all following calls of SuppressSystemMessageBox() will be ignored. If SuppressSystemMessageBox() was executed before, that this function print out a critical error message. For example can be used in CGI applications where SuppressSystemMessageBox always calls in the CCgiApplication constructor.

Definition at line 708 of file ncbi_system.cpp.

References ERR_POST_X.

unsigned int GetCpuCount void   ) 
 

[UNIX & Windows] Return number of active CPUs (never less than 1).

Definition at line 376 of file ncbi_system.cpp.

References len.

Referenced by CThread::CThread(), CDumpSysInfo::DumpSystemInfo(), CNWAligner::EnableMultipleThreads(), CGridWorkerNode::Run(), and COMSSABase::SetThreadCount().

bool GetMemoryUsage size_t *  total,
size_t *  resident,
size_t *  shared
 

[UNIX & Windows] Return current memory usage, in bytes.

NULL arguments will not be filled in. Returns true if able to determine memory usage, and false otherwise.

Definition at line 515 of file ncbi_system.cpp.

References BOOL, CDll::eAutoUnload, CDll::eLoadNow, FAR, CDll::GetEntryPoint_Func(), GetVirtualMemoryPageSize(), len, and size.

Uint8 GetPhysicalMemorySize void   ) 
 

[UNIX & Windows] Return the amount of physical memory available on the machine.

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

Definition at line 459 of file ncbi_system.cpp.

References GetVirtualMemoryPageSize(), and len.

unsigned long GetVirtualMemoryPageSize void   ) 
 

[UNIX & Windows] Return granularity with which virtual memory is allocated.

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

Definition at line 423 of file ncbi_system.cpp.

References si.

Referenced by CMemoryFile_Base::CMemoryFile_Base(), CSeqDBMapStrategy::CSeqDBMapStrategy(), GetMemoryUsage(), GetPhysicalMemorySize(), and CTar::x_Init().

static void s_ExitHandler void   )  [static]
 

static void s_SignalHandler int  sig  )  [static]
 

bool SetCpuTimeLimit size_t  max_cpu_time,
TLimitsPrintHandler  handler = 0,
TLimitsPrintParameter  parameter = 0,
size_t  terminate_time = 5
 

[UNIX only] Set CPU usage limit.

Set the limit for the CPU time that can be consumed by current process.

Parameters:
max_cpu_time The maximal amount of seconds of CPU time can be consumed by the process. The 0 value lift off the CPU time restrictions.
handler Pointer to a print handler used for dump output. Use default handler if passed as NULL.
parameter Parameter carried into the print handler. Can be passed as NULL. The time in seconds, that have the process to terminate itself after receiving a signal about exceeding CPU usage limit. After that it can be killed by OS.
Returns:
Completion status.

Definition at line 359 of file ncbi_system.cpp.

bool SetHeapLimit size_t  max_heap_size,
TLimitsPrintHandler  handler = 0,
TLimitsPrintParameter  parameter = 0
 

[UNIX only] Set memory limit.

Set the limit for the size of dynamic memory (heap) allocated by the process.

Parameters:
max_heap_size The maximal amount of dynamic memory can be allocated by the process in any `operator new' (but not malloc, etc.!). The 0 value lift off the heap restrictions.
handler Pointer to a print handler used for dump output. Use default handler if passed as NULL.
parameter Parameter carried into the print handler. Can be passed as NULL.
Returns:
Completion status.

Definition at line 293 of file ncbi_system.cpp.

void SleepMicroSec unsigned long  mc_sec,
EInterruptOnSignal  onsignal
 

Definition at line 588 of file ncbi_system.cpp.

References eInterruptOnSignal, errno, and kMicroSecondsPerSecond.

Referenced by CRequestRateControl::Sleep(), SleepMilliSec(), SleepSec(), and CReader::WaitBeforeNewConnection().

void SleepMilliSec unsigned long  ml_sec,
EInterruptOnSignal  onsignal
 

Definition at line 639 of file ncbi_system.cpp.

References SleepMicroSec().

Referenced by CBlobStorage_NetCache::CreateOStream(), SNetServiceImpl::DiscoverServers(), CNetServer::ExecWithRetry(), CGridCgiApplication::ProcessRequest(), CBlobStorage_NetCache::Reset(), CProjectServiceTestJob::Run(), CAppJobTestApplication::Run(), CPeriodicTestJob::Run(), CSampleNetScheduleNode::Run(), s_ProcessErrorCode(), CThreadPoolEngine::ShutDown(), CPrimeNumberClient::StartJobs(), CThreadPoolEngine::x_OnRequestStatusChange(), CAffinityDict::x_RemoveToken(), and CNetBLASTUIDataSource::x_WaitForDBLoadJob().

void SleepSec unsigned long  sec,
EInterruptOnSignal  onsignal = eRestartOnSignal
 

Sleep.

Suspend execution for a time.

Sleep for at least the specified number of microsec/millisec/seconds. Time slice restrictions are imposed by platform/OS. On UNIX the sleep can be interrupted by a signal. Sleep*Sec(0) have no effect (but may cause context switches).

[UNIX & Windows]

Definition at line 649 of file ncbi_system.cpp.

References kMicroSecondsPerSecond, and SleepMicroSec().

Referenced by BOOST_AUTO_TEST_CASE(), CGBenchMonitorApp::Run(), CSampleIdleTask::Run(), CRequestRateControl::Sleep(), and CRemoteBlast::x_PollUntilDone().

void SuppressSystemMessageBox TSuppressSystemMessageBox  mode = fSuppress_Default  ) 
 

Suppress popup messages on execution errors.

NOTE: MS Windows-specific. Suppresses all error message boxes in both runtime and in debug libraries, as well as all General Protection Fault messages.

Definition at line 675 of file ncbi_system.cpp.

References fSuppress_Debug, fSuppress_Exception, fSuppress_Runtime, and fSuppress_System.

Referenced by CCgiApplication::CCgiApplication(), main(), and CNcbiTestApplication::x_SetupBoostReporters().


Generated on Mon Dec 7 07:36:18 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:21:45 2009 by modify_doxy.py rev. 173732