#include </builds/gaudi/Gaudi/GaudiKernel/src/Lib/ProcessDescriptor.h>
|
| ProcessDescriptor ()=default |
|
virtual | ~ProcessDescriptor ()=default |
|
long | query (long pid, InfoType fetch, PROCESS_BASIC_INFORMATION *info) |
|
long | query (long pid, InfoType fetch, POOLED_USAGE_AND_LIMITS *info) |
|
long | query (long pid, InfoType fetch, KERNEL_USER_TIMES *info) |
|
long | query (long pid, InfoType fetch, QUOTA_LIMITS *info) |
|
long | query (long pid, InfoType fetch, VM_COUNTERS *info) |
|
long | query (long pid, InfoType fetch, IO_COUNTERS *info) |
|
long | query (long pid, InfoType fetch, long *info) |
|
Provides access to process information
- Author
- M.Frank
-
Sebastien Ponce
Definition at line 117 of file ProcessDescriptor.h.
◆ ProcessDescriptor()
System::ProcessDescriptor::ProcessDescriptor |
( |
| ) |
|
|
default |
◆ ~ProcessDescriptor()
virtual System::ProcessDescriptor::~ProcessDescriptor |
( |
| ) |
|
|
virtualdefault |
◆ query() [1/7]
Definition at line 343 of file ProcessDescriptor.cpp.
344 if ( info == 0 )
return 0;
348 #if defined( __linux )
352 getrusage( RUSAGE_SELF, &
usage );
353 info->ReadOperationCount =
usage.ru_inblock;
354 info->WriteOperationCount =
usage.ru_oublock;
355 info->OtherOperationCount = 0;
356 info->ReadTransferCount =
usage.ru_inblock;
357 info->WriteTransferCount =
usage.ru_oublock;
358 info->OtherTransferCount = 0;
◆ query() [2/7]
Definition at line 528 of file ProcessDescriptor.cpp.
529 if ( info == 0 )
return 0;
533 #if defined( __linux ) // Linux
534 static long long prc_start = 0;
535 bool myself = pid <= 0 || pid == ::getpid();
536 if ( myself && prc_start == 0 ) {
541 static long long offset =
542 100 *
static_cast<long long>(
time(
nullptr ) ) -
static_cast<long long>( times( &tmsb ) );
543 prc_start = ( prc.
starttime + offset ) * TICK_TO_100NSEC;
549 info->UserTime = tmsb.tms_utime * TICK_TO_100NSEC;
550 info->KernelTime = tmsb.tms_stime * TICK_TO_100NSEC;
551 info->CreateTime = prc_start;
556 static long long offset =
557 100 *
static_cast<long long>(
time(
nullptr ) ) -
static_cast<long long>( times( &tmsb ) );
561 info->UserTime =
t.tms_utime * TICK_TO_100NSEC;
562 info->KernelTime =
t.tms_stime * TICK_TO_100NSEC;
563 info->CreateTime = ( prc.
starttime + offset ) * TICK_TO_100NSEC;
569 #elif defined( __APPLE__ )
573 #else // no /proc file system: assume sys_start for the first call
575 static clock_t sys_start = times( 0 );
576 static long long offset = 100 *
long long(
time( 0 ) ) - sys_start;
577 clock_t now = times( &tmsb );
578 info->CreateTime = offset + now;
579 info->UserTime = tmsb.tms_utime;
580 info->KernelTime = tmsb.tms_stime;
581 info->CreateTime *= TICK_TO_100NSEC;
582 info->UserTime *= TICK_TO_100NSEC;
583 info->KernelTime *= TICK_TO_100NSEC;
◆ query() [3/7]
long System::ProcessDescriptor::query |
( |
long |
pid, |
|
|
InfoType |
fetch, |
|
|
long * |
info |
|
) |
| |
◆ query() [4/7]
Definition at line 366 of file ProcessDescriptor.cpp.
367 if ( info == 0 )
return 0;
371 #if defined( __linux ) // Linux
376 getrlimit( RLIMIT_DATA, &lim );
377 if ( lim.rlim_max == RLIM_INFINITY ) lim.rlim_max = 0xFFFFFFFF;
378 info->PeakPagedPoolUsage = lim.rlim_cur;
379 info->PagedPoolUsage = lim.rlim_cur;
380 info->PagedPoolLimit = lim.rlim_max;
382 getrlimit( RLIMIT_STACK, &lim );
383 if ( lim.rlim_max == RLIM_INFINITY ) lim.rlim_max = 0xFFFFFFFF;
384 info->PeakNonPagedPoolUsage = lim.rlim_cur;
385 info->NonPagedPoolUsage = lim.rlim_cur;
386 info->NonPagedPoolLimit = lim.rlim_max;
390 info->PeakPagefileUsage = prc.
rss * pg_size;
391 info->PagefileUsage = prc.
rss * pg_size;
392 info->PagefileLimit = 0xFFFFFFFF;
393 #elif defined( __APPLE__ )
◆ query() [5/7]
Definition at line 502 of file ProcessDescriptor.cpp.
503 if ( info == 0 )
return 0;
507 #if defined( __linux ) // Linux
509 pid = processID( pid );
511 info->ExitStatus = 0;
513 info->BasePriority = 2 * 15 - prc.
priority;
516 info->AffinityMask = prc.
flags;
519 info->UniqueProcessId = pid;
520 info->InheritedFromUniqueProcessId = prc.
ppid;
◆ query() [6/7]
Definition at line 461 of file ProcessDescriptor.cpp.
462 if ( info == 0 )
return 0;
466 #if defined( __linux ) // Linux
470 if ( pid > 0 && pid != ::getpid() )
return 0;
473 getrlimit( RLIMIT_DATA, &lim );
474 if ( lim.rlim_max == RLIM_INFINITY ) lim.rlim_max = 0xFFFFFFFF;
475 info->PagedPoolLimit = lim.rlim_max;
477 getrlimit( RLIMIT_STACK, &lim );
478 if ( lim.rlim_max == RLIM_INFINITY ) lim.rlim_max = 0xFFFFFFFF;
479 info->NonPagedPoolLimit = lim.rlim_max;
480 info->MinimumWorkingSetSize = 0;
482 getrlimit( RLIMIT_RSS, &lim );
483 if ( lim.rlim_max == RLIM_INFINITY ) lim.rlim_max = 0xFFFFFFFF;
484 info->MaximumWorkingSetSize = lim.rlim_max;
486 getrlimit( RLIMIT_AS, &lim );
487 if ( lim.rlim_max == RLIM_INFINITY ) lim.rlim_max = 0xFFFFFFFF;
488 info->PagefileLimit = lim.rlim_max;
490 getrlimit( RLIMIT_CPU, &lim );
491 if ( lim.rlim_max == RLIM_INFINITY ) lim.rlim_max = 0xFFFFFFFF;
492 info->TimeLimit = lim.rlim_max;
493 #elif defined( __APPLE__ )
◆ query() [7/7]
Definition at line 423 of file ProcessDescriptor.cpp.
424 if ( info == 0 )
return 0;
428 #if defined( __linux ) // Linux
429 const ssize_t bufsize = 1024;
431 pid = processID( pid );
432 sprintf( buf,
"/proc/%ld/statm", pid );
433 long size, resident, share, trs, lrs, drs, dt;
434 int fd = open( buf, O_RDONLY );
435 ssize_t nread =
read(
fd, buf, bufsize );
437 if ( nread < bufsize && nread >= 0 ) buf[nread] =
'\0';
438 fd = sscanf( buf,
"%ld %ld %ld %ld %ld %ld %ld", &
size, &resident, &share, &trs, &drs, &lrs, &dt );
441 info->PeakVirtualSize = prc.
vsize;
442 info->VirtualSize = prc.
vsize;
443 info->PeakWorkingSetSize = resident * pg_size;
444 info->WorkingSetSize = resident * pg_size;
445 info->QuotaPeakPagedPoolUsage = share * pg_size;
446 info->QuotaPagedPoolUsage = share * pg_size;
447 info->QuotaNonPagedPoolUsage = ( trs + drs ) * pg_size;
448 info->QuotaPeakNonPagedPoolUsage = ( trs + drs ) * pg_size;
450 info->PagefileUsage = prc.
vsize - resident * pg_size;
451 info->PeakPagefileUsage = prc.
vsize - resident * pg_size;
452 #elif defined( __APPLE__ )
The documentation for this class was generated from the following files: