casacore
Loading...
Searching...
No Matches
HostInfoHpux.h
Go to the documentation of this file.
1//# HostInfo_hpux.h: HP/UX specific memory, swap, and CPU code.
2
3 /*
4 ** This is a greatly MODIFIED version of a "top" machine dependent file.
5 ** The only resemblance it bears to the original is with respect to the
6 ** mechanics of finding various system details. The copyright details
7 ** follow.
8 **
9 ** --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
10 **
11 ** Top users/processes display for Unix
12 ** Version 3
13 **
14 ** This program may be freely redistributed,
15 ** but this entire comment MUST remain intact.
16 **
17 ** Copyright (c) 1984, 1989, William LeFebvre, Rice University
18 ** Copyright (c) 1989 - 1994, William LeFebvre, Northwestern University
19 ** Copyright (c) 1994, 1995, William LeFebvre, Argonne National Laboratory
20 ** Copyright (c) 1996, William LeFebvre, Group sys Consulting
21 ** Copyright (c) 2002, Associated Universities Inc.
22 */
23
24#ifndef CASA_HOSTINFOHPUX_H
25#define CASA_HOSTINFOHPUX_H
26
27# if defined(HOSTINFO_DO_IMPLEMENT)
28
29/*
30 * AUTHOR: Darrell Schiebel <drs@nrao.edu>
31 *
32 * ORIGINAL AUTHOR: John Haxby <john_haxby@hp.com>
33 * ORIGINAL CONTRIBUTORS: Rich Holland <holland@synopsys.com>
34 * Kevin Schmidt <kevin@mcl.ucsb.edu>
35 */
36
37#include <stdio.h>
38#include <errno.h>
39#include <stdlib.h>
40#include <unistd.h>
41#include <sys/param.h>
42#include <sys/pstat.h>
43
44namespace casacore { //# NAMESPACE CASACORE - BEGIN
45
46// <summary>
47// HostInfo for HP-UX machines.
48// </summary>
49
50// <use visibility=local>
51
52// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
53// </reviewed>
54
55// <prerequisite>
56// <li> <linkto class=HostInfo>HostInfo</linkto>
57// </prerequisite>
58
59// <synopsis>
60// This file provides the HP-UX specific functions for HostInfo.
61// It is selectively included by HostInfo.cc.
62// </synopsis>
63//
64// <group name="HostInfo">
65
66/* these are for getting the memory statistics */
67
68/* Log base 2 of 1024 is 10 (2^10 == 1024) */
69#define LOG1024 10
70
71/* define pagetok in terms of pageshift */
72#define pagetok(size) ((size) << pageshift)
73
74class HostMachineInfo {
75friend class HostInfo;
76
77 HostMachineInfo( );
78 void update_info( );
79
80 int valid;
81 int cpus;
82
83 ptrdiff_t swap_total;
84 ptrdiff_t swap_used;
85 ptrdiff_t swap_free;
86
87 ptrdiff_t memory_total;
88 ptrdiff_t memory_used;
89 ptrdiff_t memory_free;
90
91 int pageshift; /* log base 2 of the pagesize */
92};
93
94// </group>
95
96
97HostMachineInfo::HostMachineInfo( ) :valid(1) {
98
99 struct pst_static info;
100 int pagesize;
101
102 if (pstat_getstatic (&info, sizeof (info), 1, 0) < 0) {
103 perror ("pstat_getstatic");
104 valid = 0;
105 }
106
107 /*
108 * Calculate pageshift -- the value needed to convert pages to Kbytes.
109 * This will usually be 2.
110 */
111 pageshift = 0;
112 for (pagesize = info.page_size; pagesize > 1; pagesize >>= 1)
113 pageshift += 1;
114 pageshift -= LOG1024;
115
116 static struct pst_dynamic dynamic;
117
118 pstat_getdynamic (&dynamic, sizeof (dynamic), 1, 0);
119 cpus = dynamic.psd_proc_cnt;
120 memory_total = pagetok (dynamic.psd_rm);
121}
122
123void HostMachineInfo::update_info( ) {
124
125 static struct pst_dynamic dynamic;
126
127 pstat_getdynamic (&dynamic, sizeof (dynamic), 1, 0);
128 memory_used = pagetok (dynamic.psd_arm);
129 memory_free = memory_total - memory_used;
130 swap_total = pagetok (dynamic.psd_vm);
131 swap_used = pagetok (dynamic.psd_avm);
132 swap_free = swap_total - swap_used;
133}
134
135# endif
136
137} //# NAMESPACE CASACORE - END
138
139#endif
this file contains all the compiler specific defines
Definition mainpage.dox:28