Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > M


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


monitor() — prepare execution profile


#include <mon.h> void monitor( void (*lowpc)(), void (*highpc)(), WORD *buffer, int bufsize, int nfunc );


An executable program created by cc -p automatically includes calls for monitor() with default parameters; monitor() need not be called explicitly except to gain fine control over profiling.

monitor() is an interface to profil(2). lowpc and highpc are the addresses of two functions; buffer is the address of a (user-supplied) array of bufsize WORDs (defined in the <mon.h> header file). The address should have proper alignment to be cast to type struct hdr and struct cnt in <mon.h>.

monitor() arranges to record in the buffer a histogram of periodically sampled values of the program counter, and of counts of calls of certain functions. The lowest address sampled is that of lowpc and the highest is just below highpc. lowpc must not equal 0 for this use of monitor. Not more than nfunc call counts can be kept; only calls of functions compiled with the profiling option -p of cc are recorded. (The C Library and Math Library supplied when cc -p is used also have call counts recorded.)

For results to be significant, especially where there are small, heavily used routines, it is suggested that the buffer be no more than a few times smaller than the range of locations sampled.

To profile the entire program, it is sufficient to use

extern etext; ... monitor ((int (*)())2, ((int(*)())& etext, buf, bufsize, nfunc);

etext lies just above all the program text (see end(3C)).

To stop execution monitoring and write the results on file mon.out, use

monitor ((int (*)())0, (int(*)())0, 0, 0, 0);

prof(1) can then be used to examine the results.


/usr/lib/libc.a /usr/lib/libm.a mon.out


monitor(): SVID2, SVID3, XPG2

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.