Copy on Write page faults

Hello

Please can you tell me how to access COPY ON WRITE page faults in HP -UNIX.
I found the structure in
/usr/include/sys/vmmeter with the structure name vmmeter.
Please tell me the function to fill the values to this structure and also
the arguments for function.::

This is going to take a little legwork, but I can get you pointed in the right direction.

That line:
extern struct vmmeter cnt, rate, sum;
is the key. You will need to look at those structures to see how they're used. I see all three when I run "nm /stand/vmunix".

To read them, you need to run nlist() on vmunix to get the address. Then open /dev/kmem and lseek() to the address that you got from nlist(). And finally just read() the structure.

It might be useful to look at the source code for some versions of vmstat. This thread lists some locations that have source code.

Hello

#include <sys/pstat.h>
#include <sys/param.h>
#include <sys/unistd.h>
#include <nlist.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/vmmeter.h>
main()
{
int fp;
struct nlist nl;
struct vmmeter l;
long OFF=11131040L; /
this address i got through nm command for cnt */
fp=open("/dev/kmem", O_RDONLY);
nlist("vmunix",&nl);
printf("%s",nl.n_name);
l=(struct vmmeter *) malloc(sizeof(struct vmmeter));

      lseek\(fp,OFF,SEEK_SET\);
      read\(fp,l,sizeof\(struct vmmeter\)\);
      printf\("%ld\\n",l-&gt;v_free\);

      \}

There is no point in calling nlist if you are going to ignore the address it returns. If nlist isn't working, you need to fix the problem. There is a bit of a standard among system programmers: if you are going to read a kernel strucre called "cnt", you should call the structure in which you store it "cnt".

#include <sys/param.h>
#include <sys/unistd.h>
#include <nlist.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/vmmeter.h>
main()
  {
        int fp;
        static struct nlist nl[2] = { {"cnt"},  {NULL} };
        struct vmmeter cnt;
        int off;
        fp=open("/dev/kmem", O_RDONLY);
        nlist("/stand/vmunix",&nl);
        off=nl[0].n_value;
        lseek(fp,off,SEEK_SET);
        read(fp,cnt,sizeof(struct vmmeter));
        printf("%ld\n",cnt.v_free);

}

Hello sir ,

  I have given the offset address by using nm command.

Later i directly substituted it in the lseek. The values that i got
are wrong , in the program which you have given.I have compared the value of free space from your program by using v_free in vmmeter and standard vmstat command . They both don't tally So is there any other method to find out cow value..

Thank you very much for giving me answer

Oppps...I have a bug...
change that read to be...
read(fp,&cnt,sizeof(struct vmmeter));

Also, I never said that cnt was the right structure to jibe with vmstat; however, after fixing the bug, it does indeed seem to match vmstat's output fairly closely. It won't be exact since I can't run the two programs simultaneously.