{  PURPOSE:
{    This procedure is used to add or subtract to the current permanent
{    or temporary file space accumulator for a job.
{    It may only be called from monitor.
{
{  DESIGN:
{    If the system attribute for dynamic file space limits is false,
{    this procedure returns with no action.
{
{    The accumlator is incremented by the specified amount.
{
{    If the accumulator is greater than the maximum limit, a monitor
{    fault of file space limit exceeded is sent, and warning limit
{    checking is turned off.
{
{    If file space warning checking is currently turned on, and the accumulator
{    is greater than the warning limit then the av monitor statistics handler
{    is activated.
{
{    Any time the accumulator is less than the warning limit, warning limit
{    checking is turned on.

  PROCEDURE [INLINE] sfp$mtr_accumulate_file_space
    (    file_space_limit_kind: sft$file_space_limit_kind;
         accumulator: sft$counter;
     VAR maximum_exceeded: boolean);

?? PUSH (LISTEXT := ON) ??

    VAR
      accumulator_p: ^sft$counter,
      cst_p: ^ost$cpu_state_table,
      ignore_status: syt$monitor_status,
      job_maximum_limit_p: ^sft$counter,
      job_warning_checking_p: ^boolean,
      job_warning_limit_p: ^sft$counter,
      monitor_fault: ost$monitor_fault,
      sac_p: ^mmt$segment_access_condition;

    maximum_exceeded := FALSE;

    cst_p := mtf$cst_p ();

{ Set up pointers to the appropriate file space limit values. (permanent or
{ temporary based on the input parameter)

    CASE file_space_limit_kind OF
    = sfc$perm_file_space_limit =
      accumulator_p := ^cst_p^.ijle_p^.statistics.perm_file_space;
      job_maximum_limit_p := ^cst_p^.jcb_p^.perm_file_job_maximum_limit;
      job_warning_checking_p := ^cst_p^.jcb_p^.perm_file_job_warning_checking;
      job_warning_limit_p := ^cst_p^.jcb_p^.perm_file_job_warning_limit;

    = sfc$temp_file_space_limit =
      accumulator_p := ^cst_p^.ijle_p^.statistics.temp_file_space;
      job_maximum_limit_p := ^cst_p^.jcb_p^.temp_file_job_maximum_limit;
      job_warning_checking_p := ^cst_p^.jcb_p^.temp_file_job_warning_checking;
      job_warning_limit_p := ^cst_p^.jcb_p^.temp_file_job_warning_limit;

    ELSE

{ No action.

      RETURN; {----->

    CASEND;

{ Add the delta to the accumulator.

    IF (UPPERVALUE (sft$counter) - accumulator_p^) <= accumulator THEN
      accumulator_p^ := UPPERVALUE (sft$counter);
    ELSE
      accumulator_p^ := accumulator_p^ +accumulator;
    IFEND;

{ It should not be possible for the accumulator to go below zero.
{ If for some reason it does it will be reset to zero.

    IF accumulator_p^ <= 0 THEN
      accumulator_p^ := 0;
      RETURN; {----->
    IFEND;

{ IF allocation is occuring check the maximum and warning limits.

    IF accumulator > 0 THEN

{ If the maximum is reached turn warning checking off and send a monitor fault.

      IF accumulator_p^ >= job_maximum_limit_p^ THEN

        maximum_exceeded := TRUE;
        job_warning_checking_p^ := FALSE;

{ If monitor was called from ring 2 or below then don't send a monitor fault.

        IF cst_p^.xcb_p^.xp.p_register.pva.ring > osc$tmtr_ring THEN
          monitor_fault.identifier := mmc$segment_fault_processor_id;
          sac_p := #LOC (monitor_fault.contents);
          CASE file_space_limit_kind OF
          = sfc$perm_file_space_limit =
            sac_p^.identifier := mmc$sac_pf_space_limit_exceeded;
          ELSE {sfc$temp_file_space_Limit}
            sac_p^.identifier := mmc$sac_tf_space_limit_exceeded;
          CASEND;
          sac_p^.segment := #ADDRESS (1, mmv$last_segment_accessed, 0);
          tmp$send_monitor_fault (cst_p^.taskid, #LOC (monitor_fault), FALSE);
        IFEND;

{ If the warning is reached activate the monitor statistics handler.

      ELSEIF job_warning_checking_p^ AND (accumulator_p^ >=
            job_warning_limit_p^) THEN
        tmp$set_system_flag (cst_p^.jcb_p^.job_monitor_id,
              avc$monitor_statistics_flag, ignore_status);

{ If neither condition currently exists, make sure that the warning limit is
{ turned on
{ any time the accumulator goes below the warning limit.

      ELSEIF accumulator_p^ < job_warning_limit_p^ THEN
        job_warning_checking_p^ := TRUE;
      IFEND;

{ If deallocation is occuring make sure that the warning limit is turned on
{ any time the accumulator goes below the warning limit.

    ELSEIF accumulator_p^ < job_warning_limit_p^ THEN
      job_warning_checking_p^ := TRUE;
    IFEND;

  PROCEND sfp$mtr_accumulate_file_space;

*copyc mmd$segment_access_condition
*copyc sft$counter
*copyc sft$file_space_limit_kind
*copyc mtf$cst_p
*copyc tmp$send_monitor_fault
*copyc tmp$set_system_flag
*copyc mmv$last_segment_accessed
?? POP ??
