"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/bsd/pagemeter.cc" (11 Jul 2020, 1783 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 "pagemeter.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 //
   10 //  This file may be distributed under terms of the GPL or of the BSD
   11 //    license, whichever you choose.  The full license notices are
   12 //    contained in the files COPYING.GPL and COPYING.BSD, which you
   13 //    should have received.  If not, contact one of the xosview
   14 //    authors for a copy.
   15 //
   16 
   17 #include "pagemeter.h"
   18 #include "kernel.h"
   19 #include <stdlib.h>
   20 
   21 
   22 PageMeter::PageMeter( XOSView *parent, double total )
   23     : FieldMeterGraph( parent, 3, "PAGE", "IN/OUT/IDLE" ) {
   24     total_ = total;
   25     BSDPageInit();
   26     BSDGetPageStats(NULL, previnfo_);
   27 }
   28 
   29 PageMeter::~PageMeter( void ) {
   30 }
   31 
   32 void PageMeter::checkResources( void ) {
   33     FieldMeterGraph::checkResources();
   34 
   35     setfieldcolor( 0, parent_->getResource("pageInColor") );
   36     setfieldcolor( 1, parent_->getResource("pageOutColor") );
   37     setfieldcolor( 2, parent_->getResource("pageIdleColor") );
   38     priority_ = atoi( parent_->getResource("pagePriority") );
   39     dodecay_ = parent_->isResourceTrue("pageDecay");
   40     useGraph_ = parent_->isResourceTrue("pageGraph");
   41     SetUsedFormat( parent_->getResource("pageUsedFormat") );
   42 }
   43 
   44 void PageMeter::checkevent( void ) {
   45     getpageinfo();
   46     drawfields();
   47 }
   48 
   49 void PageMeter::getpageinfo( void ) {
   50     uint64_t info[2];
   51     BSDGetPageStats(NULL, info);
   52 
   53     fields_[0] = info[0] - previnfo_[0];
   54     fields_[1] = info[1] - previnfo_[1];
   55     previnfo_[0] = info[0];
   56     previnfo_[1] = info[1];
   57 
   58     if (total_ < fields_[0] + fields_[1])
   59         total_ = fields_[0] + fields_[1];
   60 
   61     fields_[2] = total_ - fields_[0] - fields_[1];
   62     setUsed(total_ - fields_[2], total_);
   63 }