"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/bsd/memmeter.cc" (11 Jul 2020, 2274 Bytes) of package /linux/misc/xosview-1.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "memmeter.cc" see the Fossies "Dox" file reference documentation.

    1 //
    2 //  Copyright (c) 1994, 1995 by Mike Romberg ( romberg@fsl.noaa.gov )
    3 //
    4 //  NetBSD port:
    5 //  Copyright (c) 1995, 1996, 1997-2002 by Brian Grayson (bgrayson@netbsd.org)
    6 //
    7 //  This file was originally written by Brian Grayson for the NetBSD and
    8 //    xosview projects.
    9 //  The NetBSD memmeter was improved by Tom Pavel (pavel@slac.stanford.edu)
   10 //    to provide active and inactive values, rather than just "used."
   11 //
   12 //  This file may be distributed under terms of the GPL or of the BSD
   13 //    license, whichever you choose.  The full license notices are
   14 //    contained in the files COPYING.GPL and COPYING.BSD, which you
   15 //    should have received.  If not, contact one of the xosview
   16 //    authors for a copy.
   17 //
   18 
   19 #include "memmeter.h"
   20 #include "defines.h"
   21 #include "kernel.h"
   22 #include <stdlib.h>
   23 
   24 
   25 MemMeter::MemMeter( XOSView *parent )
   26 #if defined(HAVE_UVM)
   27     : FieldMeterGraph( parent, 4, "MEM", "ACT/INACT/WRD/FREE" ) {
   28 #else
   29     : FieldMeterGraph( parent, 5, "MEM", "ACT/INACT/WRD/CA/FREE" ) {
   30 #endif
   31     BSDPageInit();
   32 }
   33 
   34 MemMeter::~MemMeter( void ) {
   35 
   36 }
   37 
   38 void MemMeter::checkResources( void ) {
   39     FieldMeterGraph::checkResources();
   40 
   41     setfieldcolor( 0, parent_->getResource("memActiveColor") );
   42     setfieldcolor( 1, parent_->getResource("memInactiveColor") );
   43     setfieldcolor( 2, parent_->getResource("memWiredColor") );
   44 #if defined(HAVE_UVM)
   45     setfieldcolor( 3, parent_->getResource("memFreeColor") );
   46 #else
   47     setfieldcolor( 3, parent_->getResource("memCacheColor") );
   48     setfieldcolor( 4, parent_->getResource("memFreeColor") );
   49 #endif
   50     priority_ = atoi( parent_->getResource("memPriority") );
   51     dodecay_ = parent_->isResourceTrue("memDecay");
   52     useGraph_ = parent_->isResourceTrue("memGraph");
   53     SetUsedFormat( parent_->getResource("memUsedFormat") );
   54 }
   55 
   56 void MemMeter::checkevent( void ) {
   57     getmeminfo();
   58     drawfields();
   59 }
   60 
   61 void MemMeter::getmeminfo( void ) {
   62     BSDGetPageStats(meminfo_, NULL);
   63     fields_[0] = (double)meminfo_[0];
   64     fields_[1] = (double)meminfo_[1];
   65     fields_[2] = (double)meminfo_[2];
   66 #if defined(HAVE_UVM)
   67     fields_[3] = (double)meminfo_[4];
   68 #else
   69     fields_[3] = (double)meminfo_[3];
   70     fields_[4] = (double)meminfo_[4];
   71 #endif
   72     total_ = (double)(meminfo_[0] + meminfo_[1] + meminfo_[2] + meminfo_[3] + meminfo_[4]);
   73     setUsed(total_ - (double)meminfo_[4], total_);
   74 }