Source: uvgetprocessinfo.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
                          uvGetProcesssInfo.h  -  description
                             -------------------
    begin                : Son Okt 13 2002
    copyright            : (C) 2002 by Werner Schulte
    email                : werner@schulte.-ac.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef UVGETPROCESSINFO_H
#define UVGETPROCESSINFO_H


extern "C"
{
  #include 
  #include 
  #include 
  #include 
  #include 
  #include 
}

#define MAXMEM    7

enum mem_t   { total=0,
               resident=1,
               shared=2,
               code=3,
               data_stack=4,
               library=5,
               dirty=6
             };

typedef struct
        {
          long cont[MAXMEM];
        } meminfo;

typedef struct
        {
          meminfo actual, average, max;
        } memx;

/**
  This Class provides unix/linux process information.

  @author Werner Schulte (email : werner@schulte-ac.de, homepage : www.uv-ac.de)
  @version 0.1.0 - sc - 13.10.2002

  At the moment only the own PID and the systems memory page size are presented.
  **/

class uvProcessInfo
{
public:
  int mypid, mypagesize;

  /**
    returns the own process ID.
    **/
  int getMyPid( );
  /**
    returns the systems memory pagesize (in bytes).
    **/
  int getMyPageSize( );
  /**
    constructor
    **/
  uvProcessInfo( );
  /**
    destructor
    **/
  ~uvProcessInfo();
};

/**
  This Class provides process memory information.

  @author Werner Schulte (email : werner@schulte-ac.de, homepage : www.uv-ac.de)
  @version 0.1.0 - sc - 13.10.2002

  The method investigates the /proc/PID/statm file and fills an array with different
  information. The following paragraph gives an overview over the provided information.

  
    enum mem_t   { total=0,
                   resident=1,
                   shared=2,
                   code=3,
                   data_stack=4,
                   library=5,
                   dirty=6
                 };

    typedef struct
        {
          long cont[MAXMEM];
        } meminfo;

    typedef struct
        {
          meminfo actual, average, max;
        } memx;

    enum mem_t memtype;
    memx mInfo;

  
Actual provides the last read entry, while average averages all read values and max calculates the maximum read values. **/ class uvMemInfo { public: enum mem_t memtype; memx mInfo; /** returns, whether the proc file is open (found) or not. @return false, if not open, true otherwise. **/ bool getState( ); /** fills the array (actual, average and max). Note : average is not yet supported. @return false, if not successfull, true otherwise. **/ bool fillMemInfo( ); /** closes all open proc files. @return false, if not successfull, true otherwise. **/ void closeProcFiles( ); /** checks, wether the last read values has been different. This is used for diff measurement. @return false, if not different, true otherwise. **/ bool diffMemInfo(); /** constructor @p pid : the pid to investigate. @p pagesize : the pagesize for memory usage calculation. **/ uvMemInfo( int pid, int pagesize ); /** destructor The destructor closes all open files and free memory allocated. **/ ~uvMemInfo(); protected: /** opens all open proc files (at the momenmt only /proc/PID/statm). @return false, if not successfull, true otherwise. **/ bool openProcFiles( ); /** parses the procfile line and fills the actual values of the array. **/ void getLineInfo( char *line ); /** calculates the average values. **/ void getAverageInfo( int cnt ); /** calculates the maximal values. **/ void getMaxInfo( ); /** save all values for diffence decision. **/ void saveMemInfo(); private: memx mInfo1; int loopCnt, pagesize, progpid; FILE *statmfil; }; /** This Class provides samples the above mentioned clas information. @author Werner Schulte (email : werner@schulte-ac.de, homepage : www.uv-ac.de) @version 0.1.0 - sc - 13.10.2002 It creates instances of uvProcessInfo and uvMemInfo and provides some methods on that classes. The following classe are created and public accessible.
    uvProcessInfo *process;
    uvMemInfo     *mem;
  
**/ class uvGetProcessInfo { public: uvProcessInfo *process; uvMemInfo *mem; /** wraps uvMemInfo::getState(). **/ bool getMemState( ); /** wraps uvProcessInfo::getMyPid(). **/ int getMyPid( ); /** wraps uvProcessInfo::getMyPageSize(). **/ int getMyPageSize( ); /** constructor **/ uvGetProcessInfo( int pid ); /** destructor **/ ~uvGetProcessInfo(); protected: private: int progpid; }; #endif

Generated by: sc on schomep4 on Sun Nov 23 16:54:46 2003, using kdoc 2.0a54.