"Fossies" - the Fresh Open Source Software Archive 
Member "xosview-1.23/hpux/memmeter.cc" (11 Jul 2020, 1753 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 // This file may be distributed under terms of the GPL
5 //
6
7 #include "memmeter.h"
8 #include "xosview.h"
9 #include <unistd.h>
10 #include <stdlib.h>
11
12 MemMeter::MemMeter( XOSView *parent )
13 : FieldMeterDecay( parent, 4, "MEM", "TEXT/USED/OTHER/FREE" ){
14 struct pst_static pststatic;
15
16 pstat_getstatic( &pststatic, sizeof( struct pst_static ), 1, 0);
17 total_ = pststatic.physical_memory;
18 _pageSize = (int)pststatic.page_size;
19
20 stats_ = new struct pst_status[pststatic.max_proc];
21 }
22
23 void MemMeter::checkResources( void ){
24 FieldMeterDecay::checkResources();
25
26 setfieldcolor( 0, parent_->getResource( "memTextColor" ) );
27 setfieldcolor( 1, parent_->getResource( "memUsedColor" ) );
28 setfieldcolor( 2, parent_->getResource( "memOtherColor" ) );
29 setfieldcolor( 3, parent_->getResource( "memFreeColor" ) );
30 priority_ = atoi (parent_->getResource( "memPriority" ) );
31 dodecay_ = parent_->isResourceTrue( "memDecay" );
32 SetUsedFormat( parent_->getResource( "memUsedFormat" ) );
33 }
34
35 MemMeter::~MemMeter( void ){
36 delete[] stats_;
37 }
38
39 void MemMeter::checkevent( void ){
40 static int pass = 0;
41
42 pass = (pass + 1)%5;
43 if ( pass != 0 )
44 return;
45
46 getmeminfo();
47 drawfields();
48 }
49
50 void MemMeter::getmeminfo( void ){
51 struct pst_dynamic stats;
52
53 pstat_getdynamic(&stats, sizeof( pst_dynamic ), 1, 0);
54
55 struct pst_vminfo vmstats;
56 pstat_getvminfo(&vmstats, sizeof(vmstats), 1, 0);
57
58 fields_[0] = stats.psd_rmtxt + stats.psd_arm;
59 fields_[1] = stats.psd_rm - stats.psd_rmtxt;
60 fields_[2] = total_ - fields_[0] - fields_[1] - stats.psd_free;
61 fields_[3] = stats.psd_free;
62
63 FieldMeterDecay::setUsed( (total_ - fields_[3]) * _pageSize ,
64 total_ * _pageSize);
65 }
66
67