monitor(3c) DG/UX 4.30 monitor(3c)
NAME
monitor - prepare execution profile
SYNOPSIS
#include <mon.h>
void monitor (lowpc, highpc, buffer, bufsize, nfunc)
int (*lowpc)( ), (*highpc)( );
WORD *buffer;
int bufsize, nfunc;
DESCRIPTION
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). Monitor arranges to record a
histogram of periodically sampled values of the program
counter, and counts of calls of certain functions, in the
buffer. The lowest address sampled is that of lowpc and the
highest is just below highpc. Lowpc may not equal 0 for
this use of monitor. At most nfunc call counts can be kept;
only calls of functions compiled for profiling, as with the
-p option of cc(1), are recorded.
An executable program created using the -p option with cc
automatically includes calls for monitor with default
parameters; you need not call monitor explicitly except to
gain fine control over profiling.
Space in the buffer is divided among a header (sizeof(struct
hdr) bytes), call counts (nfunc * sizeof(struct cnt) bytes),
and pc counts (the remainder, taken as an array of WORDs).
On a machine whose instructions are 32 bits in size (such as
the MC88000), a pc counts area half the size of the profiled
region (((unsigned) highpc - (unsigned) lowpc) / 2) allows
for each instruction to have its own count, thereby
maximizing precision. Providing space for fewer pc counts
results in less precision.
For the results to be significant, especially where there
are small, heavily used routines, bufsize should be computed
using definitions from the <mon.h> header file as follows:
To profile the entire program, it is sufficient to use:
extern etext();
...
monitor ((int (*)())4, etext, buf, bufsize, nfunc);
where bufsize is:
(sizeof(struct hdr) +
Licensed material--property of copyright holder(s) Page 1
monitor(3c) DG/UX 4.30 monitor(3c)
(nfunc * sizeof(struct cnt)) +
(((unsigned)etext - 4) / 2))
/ sizeof(WORD)
and buf is an array of bufsize * sizeof(WORD) bytes.
Etext lies just above all the program text; see end(3C).
To stop execution monitoring and write the results on the
file mon.out, use
monitor ((int (*)())0, (int (*)())0, 0, 0, 0);
Prof(1) can then be used to examine the results.
FILES
mon.out
/lib/libp/libc.a
/lib/libp/libm.a
SEE ALSO
profil(2), end(3C).
cc(1), prof(1) in the User's Reference for the DG/UX System
Licensed material--property of copyright holder(s) Page 2