include/corelib/ncbi_system.hpp File Reference

#include <corelib/ncbitime.hpp>

Include dependency graph for ncbi_system.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void * TLimitsPrintParameter
 Type of parameter for print handler.
typedef void(* TLimitsPrintHandler )(ELimitsExitCode, size_t, CTime &, TLimitsPrintParameter)
 Type of handler for printing a dump information after generating any limitation event.
typedef int TSuppressSystemMessageBox
 Binary OR of "ESuppressSystemMessageBox".

Enumerations

enum  ELimitsExitCode { eLEC_None, eLEC_Memory, eLEC_Cpu }
 Code for program's exit handler. More...
enum  ESuppressSystemMessageBox {
  fSuppress_System = (1<<0), fSuppress_Runtime = (1<<1), fSuppress_Debug = (1<<2), fSuppress_Exception = (1<<3),
  fSuppress_All, fSuppress_Default = fSuppress_All
}
 Suppress modes. More...

Functions

bool SetHeapLimit (size_t max_heap_size, TLimitsPrintHandler handler=0, TLimitsPrintParameter parameter=0)
 [UNIX only] Set memory limit.
bool SetCpuTimeLimit (size_t max_cpu_time, TLimitsPrintHandler handler=0, TLimitsPrintParameter parameter=0, size_t terminate_time=5)
 [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 SleepSec (unsigned long sec, EInterruptOnSignal onsignal=eRestartOnSignal)
 Sleep.
void SleepMilliSec (unsigned long ml_sec, EInterruptOnSignal onsignal=eRestartOnSignal)
void SleepMicroSec (unsigned long mc_sec, EInterruptOnSignal onsignal=eRestartOnSignal)
void SuppressSystemMessageBox (TSuppressSystemMessageBox mode=fSuppress_Default)
 Suppress popup messages on execution errors.
void DisableSuppressSystemMessageBox ()
 Prevent run of SuppressSystemMessageBox().


Typedef Documentation

typedef void(* TLimitsPrintHandler)(ELimitsExitCode, size_t, CTime &, TLimitsPrintParameter)
 

Type of handler for printing a dump information after generating any limitation event.

Definition at line 71 of file ncbi_system.hpp.

typedef void* TLimitsPrintParameter
 

Type of parameter for print handler.

Definition at line 67 of file ncbi_system.hpp.

typedef int TSuppressSystemMessageBox
 

Binary OR of "ESuppressSystemMessageBox".

Definition at line 192 of file ncbi_system.hpp.


Enumeration Type Documentation

enum ELimitsExitCode
 

Code for program's exit handler.

If, during the program execution, the process exceed any from limits (see ELimitsExitCodeMemory) then: 1) Dump info about current program's state to log-stream.

  • if defined print handler "handler", then it will be used.
  • if defined "parameter", it will be passed into print handler; 2) Terminate the program. One joint print handler for all limit types is used.
Enumerator:
eLEC_None  Normal exit.
eLEC_Memory  Memory limit.
eLEC_Cpu  CPU usage limit.

Definition at line 60 of file ncbi_system.hpp.

enum ESuppressSystemMessageBox
 

Suppress modes.

Enumerator:
fSuppress_System  System errors.
fSuppress_Runtime  Runtime library.
fSuppress_Debug  Debug library.
fSuppress_Exception  Unhandled exceptions.
fSuppress_All 
fSuppress_Default 

Definition at line 182 of file ncbi_system.hpp.


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().

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 = eRestartOnSignal
 

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 = eRestartOnSignal
 

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(), CSampleNetScheduleNode::Run(), CPeriodicTestJob::Run(), CAppJobTestApplication::Run(), CProjectServiceTestJob::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(), CSampleIdleTask::Run(), CGBenchMonitorApp::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 Sun Dec 6 23:20:21 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:21:19 2009 by modify_doxy.py rev. 173732