"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/bsd/intratemeter.cc" (11 Jul 2020, 2045 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 "intratemeter.cc" see the Fossies "Dox" file reference documentation.

    1 //
    2 //  Copyright (c) 1999 by Brian Grayson (bgrayson@netbsd.org)
    3 //
    4 //  This file may be distributed under terms of the GPL or of the BSD
    5 //    license, whichever you choose.  The full license notices are
    6 //    contained in the files COPYING.GPL and COPYING.BSD, which you
    7 //    should have received.  If not, contact one of the xosview
    8 //    authors for a copy.
    9 //
   10 
   11 #include "intratemeter.h"
   12 #include "kernel.h"
   13 #include <stdlib.h>
   14 #include <strings.h>
   15 #include <err.h>
   16 
   17 
   18 IrqRateMeter::IrqRateMeter( XOSView *parent )
   19     : FieldMeterGraph( parent, 2, "IRQs", "IRQs per sec/IDLE", 1, 1, 0 ) {
   20     if (!BSDIntrInit()) {
   21         warnx("The kernel does not seem to have the symbols needed for the IrqRateMeter.");
   22         warnx("The IrqRateMeter has been disabled.");
   23         disableMeter();
   24     }
   25     irqcount_ = BSDNumInts();
   26     irqs_ = (uint64_t *)calloc(irqcount_ + 1, sizeof(uint64_t));
   27     lastirqs_ = (uint64_t *)calloc(irqcount_ + 1, sizeof(uint64_t));
   28 }
   29 
   30 IrqRateMeter::~IrqRateMeter( void ) {
   31     free(irqs_);
   32     free(lastirqs_);
   33 }
   34 
   35 void IrqRateMeter::checkResources( void ) {
   36     FieldMeterGraph::checkResources();
   37     setfieldcolor( 0, parent_->getResource("irqrateUsedColor") );
   38     setfieldcolor( 1, parent_->getResource("irqrateIdleColor") );
   39     priority_ = atoi( parent_->getResource("irqratePriority") );
   40     dodecay_ = parent_->isResourceTrue("irqrateDecay");
   41     useGraph_ = parent_->isResourceTrue("irqrateGraph");
   42     SetUsedFormat( parent_->getResource("irqrateUsedFormat") );
   43     total_ = 2000;
   44 
   45     BSDGetIntrStats(lastirqs_, NULL);
   46 }
   47 
   48 void IrqRateMeter::checkevent( void ) {
   49     getinfo();
   50     drawfields();
   51 }
   52 
   53 void IrqRateMeter::getinfo( void ) {
   54     int delta = 0;
   55 
   56     IntervalTimerStop();
   57     BSDGetIntrStats(irqs_, NULL);
   58 
   59     for (uint i = 0; i <= irqcount_; i++) {
   60         delta += irqs_[i] - lastirqs_[i];
   61         lastirqs_[i] = irqs_[i];
   62     }
   63     bzero(irqs_, (irqcount_ + 1) * sizeof(irqs_[0]));
   64 
   65     /*  Scale delta by the priority.  */
   66     fields_[0] = delta / IntervalTimeInSecs();
   67 
   68     //  Bump total_, if needed.
   69     if (fields_[0] > total_)
   70         total_ = fields_[0];
   71 
   72     setUsed(fields_[0], total_);
   73     IntervalTimerStart();
   74 }