7 // The following define is needed for SGI IRIX 6.2
11 #include <sys/param.h>
19 void KCMMemory::fetchValues()
21 int pagesize
= getpagesize();
24 if( sysmp(MP_SAGET
, MPSA_RMINFO
, &rmi
, sizeof(rmi
)) == -1 )
26 memoryInfos
[TOTAL_MEM
] = MEMORY(rmi
.physmem
) * pagesize
; // total physical memory (without swaps)
27 memoryInfos
[FREE_MEM
] = MEMORY(rmi
.freemem
) * pagesize
; // total free physical memory (without swaps)
28 memoryInfos
[BUFFER_MEM
] = MEMORY(rmi
.bufmem
) * pagesize
;
31 //FIXME: memoryInfos[CACHED_MEM]"
32 memoryInfos
[CACHED_MEM
] = NO_MEMORY_INFO
; // cached memory in ram
35 swapctl(SC_GETSWAPTOT
, &val
);
36 memoryInfos
[SWAP_MEM
] = MEMORY(val
) * UBSIZE
; // total size of all swap-partitions
38 swapctl(SC_GETFREESWAP
, &val
);
39 memoryInfos
[FREESWAP_MEM
] = MEMORY(val
) * UBSIZE
; // free memory in swap-partitions
42 /* Irix 6.5 (also 6.4?) */
43 memoryInfos
[SHARED_MEM
] = NO_MEMORY_INFO
;
45 FILE *kmem
= fopen("/dev/kmem", "r");
47 memoryInfos
[SHARED_MEM
] = NO_MEMORY_INFO
;
51 long shmip
= sysmp(MP_KERNADDR
, MPKA_SHMINFO
);
52 fseek( kmem
, shmip
, 0 );
54 fread( &shmi
, sizeof(shmi
), 1, kmem
);
56 long shmem
= sysmp(MP_KERNADDR
, MPKA_SHM
);
60 struct shmid_ds shmid
;
61 for( int i
=0 ; i
<shmi
.shmmni
; i
++ ) {
62 fseek( kmem
, shmem
, 0 );
63 shmem
+= sizeof(shmem
);
64 fread( &pos
, sizeof(shmem
), 1, kmem
);
66 fseek( kmem
, pos
, 0 );
67 fread( &shmid
, sizeof(shmid
), 1, kmem
);
68 val
+= shmid
.shm_segsz
;
71 memoryInfos
[SHARED_MEM
] = MEMORY(val
);