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 {
72 friend 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// </group>
92
93HostMachineInfo::HostMachineInfo() : valid(1) {
94 pagesize = getpagesize();
95
96 if ((cpus = sysmp(MP_NPROCS)) == -1) {
97 perror("sysmp(MP_NPROCS)");
98 valid = 0;
99 return;
100 }
101
102 struct rminfo realmem;
103 if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof(realmem)) == -1) {
104 perror("sysmp(MP_SAGET,MPSA_RMINFO, ...)");
105 valid = 0;
106 return;
107 }
108
109 memory_total = pagetok(realmem.physmem);
110}
111
112void HostMachineInfo::update_info() {
113 int i;
114 struct rminfo realmem;
115 struct sysinfo sysinfo;
116 off_t fswap; /* current free swap in blocks */
117 off_t tswap; /* total swap in blocks */
118
119 swapctl(SC_GETFREESWAP, &fswap);
120 swapctl(SC_GETSWAPTOT, &tswap);
121
122 if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof(realmem)) == -1) {
123 perror("sysmp(MP_SAGET,MPSA_RMINFO, ...)");
124 valid = 0;
125 return;
126 }
127
128 memory_free = pagetok(realmem.freemem);
129 memory_used = memory_total - memory_free;
130 swap_total = tswap / 2;
131 swap_free = fswap / 2;
132 swap_used = swap_total - swap_free;
133}
134
135#endif
136
137} // # NAMESPACE CASACORE - END
138
139#endif
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28