casacore
Loading...
Searching...
No Matches
HostInfoIrix.h
Go to the documentation of this file.
1//# HostInfo_irix.h: SGI Irix 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_HOSTINFOIRIX_H
25#define CASA_HOSTINFOIRIX_H
26
27# if defined(HOSTINFO_DO_IMPLEMENT)
28
29/*
30 * AUTHOR: Darrell Schiebel <drs@nrao.edu>
31 *
32 * ORIGINAL AUTHORS: Sandeep Cariapa <cariapa@sgi.com>
33 * Larry McVoy <lm@sgi.com>
34 * John Schimmel <jes@sgi.com>
35 * Ariel Faigon <ariel@sgi.com>
36 */
37
38#include <stdio.h>
39#include <stdlib.h>
40#include <sys/types.h>
41#include <unistd.h>
42#include <sys/stat.h>
43#include <sys/swap.h>
44#include <sys/sysmp.h>
45#include <sys/sysinfo.h>
46
47namespace casacore { //# NAMESPACE CASACORE - BEGIN
48
49// <summary>
50// HostInfo for IRIX machines.
51// </summary>
52
53// <use visibility=local>
54
55// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
56// </reviewed>
57
58// <prerequisite>
59// <li> <linkto class=HostInfo>HostInfo</linkto>
60// </prerequisite>
61
62// <synopsis>
63// This file provides the IRIX specific functions for HostInfo.
64// It is selectively included by HostInfo.cc.
65// </synopsis>
66//
67// <group name="HostInfo">
68
69#define pagetok(pages) ((((uint64_t) pages) * pagesize) >> 10)
70
71class HostMachineInfo {
72friend class HostInfo;
73
74 HostMachineInfo( );
75 void update_info( );
76
77 int valid;
78 int cpus;
79
80 ptrdiff_t swap_total;
81 ptrdiff_t swap_used;
82 ptrdiff_t swap_free;
83
84 ptrdiff_t memory_total;
85 ptrdiff_t memory_used;
86 ptrdiff_t memory_free;
87
88 ptrdiff_t pagesize;
89
90};
91
92// </group>
93
94
95HostMachineInfo::HostMachineInfo( ) : valid(1) {
96
97 pagesize = getpagesize();
98
99 if ((cpus = sysmp(MP_NPROCS)) == -1) {
100 perror("sysmp(MP_NPROCS)");
101 valid = 0;
102 return;
103 }
104
105 struct rminfo realmem;
106 if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof(realmem)) == -1) {
107 perror("sysmp(MP_SAGET,MPSA_RMINFO, ...)");
108 valid = 0;
109 return;
110 }
111
112 memory_total = pagetok(realmem.physmem);
113}
114
115void HostMachineInfo::update_info( ) {
116 int i;
117 struct rminfo realmem;
118 struct sysinfo sysinfo;
119 off_t fswap; /* current free swap in blocks */
120 off_t tswap; /* total swap in blocks */
121
122 swapctl(SC_GETFREESWAP, &fswap);
123 swapctl(SC_GETSWAPTOT, &tswap);
124
125 if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof(realmem)) == -1) {
126 perror("sysmp(MP_SAGET,MPSA_RMINFO, ...)");
127 valid = 0;
128 return;
129 }
130
131 memory_free = pagetok(realmem.freemem);
132 memory_used = memory_total - memory_free;
133 swap_total = tswap / 2;
134 swap_free = fswap / 2;
135 swap_used = swap_total - swap_free;
136}
137
138# endif
139
140} //# NAMESPACE CASACORE - END
141
142#endif
this file contains all the compiler specific defines
Definition mainpage.dox:28