[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

moncontrol Subroutine


Starts and stops execution profiling after initialization by the monitor subroutine.


Standard C Library (libc.a)


#include <mon.h>

int moncontrol ( Mode)
int Mode;


The moncontrol subroutine starts and stops profiling after profiling has been initialized by the monitor subroutine. It may be used with either -p or -pg profiling. When moncontrol stops profiling, no output data file is produced. When profiling has been started by the monitor subroutine and the exit subroutine is called, or when the monitor subroutine is called with a value of 0, then profiling is stopped, and an output file is produced, regardless of the state of profiling as set by the moncontrol subroutine.

The moncontrol subroutine examines global and parameter data in the following order:

  1. When the _mondata.prof_type global variable is neither -1 (-p profiling defined) nor +1 (-pg profiling defined), no action is performed, 0 is returned, and the function is considered complete.

    The global variable is set to -1 in the mcrt0.o file and to +1 in the gcrt0.o file and defaults to 0 when the crt0.o file is used.

  2. When the Mode parameter is 0, profiling is stopped. For any other value, profiling is started.

    The following global variables are used in a call to the profil (profil Subroutine) subroutine:

    _mondata.ProfBuf Buffer address
    _mondata.ProfBufSiz Buffer size/multirange flag
    _mondata.ProfLoPC PC offset for hist buffer - I/O limit
    _mondata.ProfScale PC scale/compute scale flag.

These variables are initialized by the monitor subroutine each time it is called to start profiling.


Mode Specifies whether to start (resume) or stop profiling.

Return Values

The moncontrol subroutine returns the previous state of profiling. When the previous state was STOPPED, a 0 is returned. When the previous state was STARTED, a 1 is returned.

Error Codes

When the moncontrol subroutine detects an error from the call to the profil subroutine, a -1 is returned.

Related Information

The monitor (monitor Subroutine) subroutine, monstartup (monstartup Subroutine) subroutine, profil (profil Subroutine) subroutine.

List of Memory Manipulation Services in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]