[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
|
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
Hello,
A customer had a program running in DEC OSF/1 V2.1 to read some kernel values.
In Digital UNIX V3.2G it works except for the value of VM_PAGE_WIRE_COUNT.
I know this value could be read from table(), but customer ask if it could be
still read from /dev/kmem.
Thanks in avance,
Jose Ignacio Lopez
(Sample Code is below)
#include <stdio.h>
#include <fcntl.h>
#include <nlist.h>
#include <sys/dk.h>
#include "cpumem.h"
#define CP_TIME 0
#define VM_PAGE_FREE_COUNT 1
#define VM_PAGE_ACTIVE_COUNT 2
#define VM_PAGE_INACTIVE_COUNT 3
#define UBC_LRU_PAGE_COUNT 4
#define VM_PAGE_WIRE_COUNT 5 /* This doesn't work in V3.2G */
#define VM_PAGE_SWAP_SPACE 6
#define VM_TOTAL_PAGE_SWAP_SPACE 7
struct nlist nl[]=
{
{ "cp_time" },
{ "vm_page_free_count" },
{ "vm_page_active_count" },
{ "vm_page_inactive_count" },
{ "ubc_lru_page_count" },
{ "vm_page_wire_count" },
{ "vm_swap_space" },
{ "vm_total_swap_space" },
{ NULL }
};
static int kmem_fd;
static long oldloadcpu[CPUSTATES] = {0,0,0,0,0};
extern cpumem_kernel_init ()
{
nlist ("/vmunix", nl);
kmem_fd = open ("/dev/kmem", O_RDONLY);
}
extern int cpumem_kernel_read (int *cpuloadp, int *memloadp,
int *swaploadp)
{
int freememory;
int activememory, actmemory, inactmemory, ubclrumemory;
int wirememory,carga_cpu;
long freeswap, totalswap;
long loadcpu[CPUSTATES], cputotal;
int i,j;
lseek (kmem_fd, nl[CP_TIME].n_value, SEEK_SET);
read (kmem_fd, &carga_cpu, sizeof (carga_cpu));
lseek (kmem_fd, nl[VM_PAGE_FREE_COUNT].n_value, SEEK_SET);
read (kmem_fd, &freememory, sizeof (freememory));
lseek (kmem_fd, nl[VM_PAGE_ACTIVE_COUNT].n_value, SEEK_SET);
read (kmem_fd, &actmemory, sizeof (actmemory));
lseek (kmem_fd, nl[VM_PAGE_INACTIVE_COUNT].n_value, SEEK_SET);
read (kmem_fd, &inactmemory, sizeof (inactmemory));
lseek (kmem_fd, nl[UBC_LRU_PAGE_COUNT].n_value, SEEK_SET);
read (kmem_fd, &ubclrumemory, sizeof (ubclrumemory));
lseek (kmem_fd, nl[VM_PAGE_WIRE_COUNT].n_value, SEEK_SET);
read (kmem_fd, &wirememory, sizeof (wirememory));
lseek (kmem_fd, nl[VM_PAGE_SWAP_SPACE].n_value, SEEK_SET);
read (kmem_fd, &freeswap, sizeof (freeswap));
lseek (kmem_fd, nl[VM_TOTAL_PAGE_SWAP_SPACE].n_value, SEEK_SET);
read (kmem_fd, &totalswap, sizeof (totalswap));
printf("carga_cpu= %d\n", carga_cpu);
printf("freeswap= %d\n",freeswap);
printf("totalswap= %d\n",totalswap);
printf("freememory= %d\n",freememory);
printf("actmemory= %d\n",actmemory);
printf("inactmemory= %d\n",inactmemory);
printf("ubclrumemory= %d\n",ubclrumemory);
printf("wirememory= %d\n",wirememory);
/* This gives a completly wrong value ****************/
/* printf("totalswap= %d\n",totalswap);
*/
activememory = actmemory + inactmemory + ubclrumemory;
printf("activememory= %d\n",activememory);
*memloadp = (int) ((wirememory + activememory) * 100L /
(freememory + activememory + wirememory));
printf("memloadp= %d\n",*memloadp);
[Posted by WWW Notes gateway]
T.R | Title | User | Personal Name | Date | Lines |
---|
8787.1 | | NETRIX::"[email protected]" | Shashi Mangalat | Wed Feb 12 1997 22:10 | 9 |
| The wired page statistics are now kept in the vm_perf structure
(it is defined in /sys/include/vm/vm_perf.h, not an exported user
include file).
table(TBL_VMSTATS) is the preferred method. Besides being faster,
it isolates the user from kernel data structure changes.
--shashi
[Posted by WWW Notes gateway]
|