moncontrol Subroutine

Purpose

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

Library

Standard C Library (libc.a)

Syntax

#include <mon.h>

int moncontrol ( Mode)
int Mode;

Description

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:

    Item Description
    _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.

Parameters

Item Description
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.