removing mem.{buffer,cached} fields.

replace with actual_{free,used} fields so we can portably adjust
-/+ buffers/cache on linux and perhaps on other platforms w/ different
semantics.
This commit is contained in:
Doug MacEachern 2004-11-20 02:08:16 +00:00
parent 41c0ee4f7c
commit fee5b18641
11 changed files with 34 additions and 24 deletions

View File

@ -143,8 +143,8 @@ namespace Hyperic.Sigar {
public readonly ulong Used;
public readonly ulong Free;
public readonly ulong Shared;
private readonly ulong NA_buffer;
private readonly ulong NA_cached;
public readonly ulong ActualFree;
public readonly ulong ActualUsed;
[DllImport(Sigar.LIBSIGAR)]
private static extern int

View File

@ -33,8 +33,8 @@ int main(int argc, char *argv[]){
meminfo.buffer / 1024,
meminfo.cached / 1024);
fprintf(stdout, "-/+ buffers/cache: %10ld %10d\n",
(meminfo.used - meminfo.buffer - meminfo.cached) / 1024,
(meminfo.free + meminfo.buffer + meminfo.cached) / 1024);
meminfo.actual_used / 1024,
meminfo.actual_free / 1024);
fprintf(stdout, "Swap: %10ld %10ld %10ld\n",
swapinfo.total / 1024,
swapinfo.used / 1024,

View File

@ -75,8 +75,8 @@ typedef struct {
used,
free,
shared,
buffer,
cached;
actual_used,
actual_free;
} sigar_mem_t;
SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem);

View File

@ -354,10 +354,10 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->total = PAGESHIFT(vm.memsizepgs); /* lsattr -El sys0 -a realmem */
mem->free = PAGESHIFT(vm.numfrb);
mem->used = mem->total - mem->free;
mem->actual_used = mem->used;
mem->actual_free = mem->free;
mem->shared = -1;
mem->buffer = -1;
mem->cached = -1;
sigar_mem_calc_ram(sigar, mem);

View File

@ -124,8 +124,9 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->used = mem->total - mem->free;
mem->shared = -1; /*XXX*/
mem->buffer = -1;
mem->cached = -1;
mem->actual_free = mem->free;
mem->actual_used = mem->used;
return SIGAR_OK;
}

View File

@ -55,7 +55,10 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->used = mem->total - mem->free;
/*XXX*/
mem->shared = mem->buffer = mem->cached = 0;
mem->shared = 0;
mem->actual_free = mem->free;
mem->actual_used = mem->used;
return SIGAR_OK;
}

View File

@ -233,6 +233,7 @@ static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
{
sigar_uint64_t buffer, cached;
char buffer[BUFSIZ];
int status = sigar_file2str(PROC_MEMINFO,
@ -244,9 +245,14 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->total = sigar_meminfo(buffer, MEMINFO_PARAM("MemTotal"));
mem->free = sigar_meminfo(buffer, MEMINFO_PARAM("MemFree"));
mem->buffer = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers"));
mem->cached = sigar_meminfo(buffer, MEMINFO_PARAM("Cached"));
mem->used = mem->total - mem->free;
buffer = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers"));
cached = sigar_meminfo(buffer, MEMINFO_PARAM("Cached"));
mem->actual_free = mem->free;
mem->actual_used = mem->used;
mem->shared = 0; /* XXX where did this go in 2.6?? */
if (get_ram(sigar, mem) != SIGAR_OK) {

View File

@ -50,8 +50,9 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
sigar_mem_calc_ram(sigar, mem);
mem->shared = -1;
mem->buffer = -1;
mem->cached = -1;
mem->actual_free = mem->free;
mem->actual_used = mem->used;
return SIGAR_OK;
}

View File

@ -180,11 +180,12 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->shared = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_EXEC));
mem->buffer = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_VNODE));
mem->cached = -1; /*XXX*/
/*mem->buffer = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_VNODE));*/
}
mem->actual_free = mem->free;
mem->actual_used = mem->used;
return SIGAR_OK;
}

View File

@ -28,9 +28,8 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->used = -1;
mem->free = -1;
mem->shared = -1;
mem->buffer = -1;
mem->cached = -1;
mem->actual_free = mem->free;
mem->actual_used = mem->used;
return SIGAR_OK;
}

View File

@ -276,9 +276,8 @@ SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
sigar_mem_calc_ram(sigar, mem);
/*XXX*/
mem->buffer = 0;
mem->cached = 0;
mem->actual_free = mem->free;
mem->actual_used = mem->used;
return SIGAR_OK;
}