?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Statistics : Emit Periodic Statistics' ??
MODULE osm$emit_os_statistics;

{ PURPOSE:
{         This module emits statistics to the global statistics log.

?? NEWTITLE := 'Global Declarations Referenced by this Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc jmt$dispatching_priority
*copyc jmt$job_class
*copyc mmt$page_frame_queue_id
*copyc mmt$page_pull_status
*copyc nac$statistics_codes
*copyc nlt$device_count
*copyc ofe$error_codes
*copyc osc$statistics
*copyc osc$processor_defined_registers
*copyc oss$task_private
*copyc oss$task_shared
*copyc ost$data_id
*copyc ost$emission_sets
*copyc ost$job_and_memory_stats
*copyc ost$paging_and_mtr_stats
?? POP ??
*copyc avp$configuration_administrator
*copyc avp$system_displays
*copyc clp$trimmed_string_size
*copyc nap$get_intranet_statistics
*copyc nap$get_namve_statistics
*copyc nap$get_osi_device_spec_stats
*copyc nap$get_osi_statistics
*copyc osp$copy_local_status_to_status
*copyc osp$get_aging_stats
*copyc osp$get_cpu_stats
*copyc osp$get_disk_space_stats
*copyc osp$get_jm_mm_stats
*copyc osp$get_job_class_stats
*copyc osp$get_job_stats
*copyc osp$get_mtr_stats
*copyc osp$get_page_stats
*copyc osp$get_paging_stats
*copyc osp$get_pio_pp_stats
*copyc osp$get_pio_unit_stats
*copyc osp$get_pp_unit_count
*copyc osp$get_service_class_stats
*copyc osp$get_swap_stats
*copyc osp$fetch_system_constant
*copyc osp$emit_os_statistics_r1
*copyc osp$read_emission_sets_r1
*copyc osp$release_manps_lock_r1
*copyc osp$reserve_manps_lock_r1
*copyc osp$set_status_abnormal
*copyc pmp$collect_raw_task_statistics
*copyc osp$write_emission_sets_r1
*copyc pmp$log
*copyc pmp$zero_out_table
*copyc sfp$emit_statistic
*copyc jmv$job_class_table_p
*copyc jmv$max_service_class_in_use
*copyc jmv$maximum_job_class_in_use
*copyc jmv$service_classes
*copyc nav$global_osi_statistics
*copyc nav$global_statistics
*copyc nav$namve_active
*copyc nav$statistics_enabled
*copyc osv$monitor_interlock_wait_time
*copyc osv$task_private_heap
*copyc osv$task_shared_heap
?? OLDTITLE ??
?? NEWTITLE := 'Global Declarations Declared by this Module', EJECT ??

  VAR
    previous_cycle_time: [oss$task_shared] integer := 0,
    previous_wait_time: [oss$task_shared] integer := 0,
    previous_delay_time: [oss$task_shared] integer := 0,
    previous_write_mod_pages_time: [oss$task_shared] integer := 0,
    previous_cycle_count: [oss$task_shared] 0 .. 0ffffffff(16) := 0,
    previous_wait_count: [oss$task_shared] 0 .. 0ffffffff(16) := 0,
    previous_delay_count: [oss$task_shared] 0 .. 0ffffffff(16) := 0,
    previous_write_mod_pages_count: [oss$task_shared] 0 .. 0ffffffff(16) := 0;

  VAR
    intranet_statistic_p: [oss$task_private] ^ost$intranet_statistics := NIL,
    namve_statistic_p: [oss$task_private] ^ost$namve_statistics := NIL,
    osi_device_specific_statistic_p: [oss$task_private] ^ost$channel_device_statistics := NIL,
    osi_statistic_p: [oss$task_private] ^ost$namve_osi_statistics := NIL;

  VAR
    aborted_condition: [oss$task_shared] integer := 0;

?? OLDTITLE ??
?? NEWTITLE := '[XDCL, #GATE] osp$read_emission_sets', EJECT ??

{ PURPOSE:
{   The purpose of this procedure is to obtain a copy of the emission sets.

  PROCEDURE [XDCL, #GATE] osp$read_emission_sets
    (VAR emission_sets: array [ost$emission_set_names] of ost$emission_set;
     VAR status: ost$status);

    VAR
      emission_sets_copy: array [ost$emission_set_names] of ost$emission_set,
      local_status: ost$status;

    IF NOT (avp$configuration_administrator () OR avp$system_displays ()) THEN
      osp$set_status_abnormal ('OF', ofe$sou_not_active, 'configuration_administration or system_displays',
            status);
      RETURN;
    IFEND;
    osp$read_emission_sets_r1 (emission_sets_copy, local_status);
    osp$copy_local_status_to_status (local_status, status);
    emission_sets := emission_sets_copy;

  PROCEND osp$read_emission_sets;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL, #GATE] osp$release_manps_lock', EJECT ??

{ PURPOSE:
{   The purpose of this request is to release the osv$manps_user_lock if
{   it is held by the calling task.

  PROCEDURE [XDCL, #GATE] osp$release_manps_lock;

    osp$release_manps_lock_r1;

  PROCEND osp$release_manps_lock;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL, #GATE] osp$reserve_manps_lock', EJECT ??

{ PURPOSE:
{   The purpose of this request is to reserve the osv$manps_user_lock for
{   the calling task.

  PROCEDURE [XDCL, #GATE] osp$reserve_manps_lock
    (VAR status: ost$status);

    VAR
      local_status: ost$status;

    status.normal := TRUE;

    IF NOT (avp$configuration_administrator () ) THEN
      osp$set_status_abnormal ('OF', ofe$sou_not_active, 'configuration_administration',status);
      RETURN;
    IFEND;

    osp$reserve_manps_lock_r1 (local_status);
    osp$copy_local_status_to_status(local_status, status);

  PROCEND osp$reserve_manps_lock;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL, #GATE] osp$write_emission_sets' , EJECT ??

{ PURPOSE:
{   This purpose of this procedure is to write the emission sets.  The calling
{   task must hold the manps_user_lock.

  PROCEDURE [XDCL, #GATE] osp$write_emission_sets
    (    emission_sets: array [ost$emission_set_names] of ost$emission_set;
     VAR status: ost$status);

    VAR
      emission_sets_copy: array [ost$emission_set_names] of ost$emission_set,
      local_status: ost$status;

    status.normal := TRUE;

    emission_sets_copy := emission_sets;
    osp$write_emission_sets_r1 (emission_sets_copy, local_status);
    osp$copy_local_status_to_status (local_status, status);

  PROCEND osp$write_emission_sets;
?? OLDTITLE ??
?? NEWTITLE := 'Statistic emitting procedures' ??
?? NEWTITLE := 'emit_job_and_memory_stats' ??
?? NEWTITLE := 'OS0' , EJECT ??

  PROCEDURE emit_job_and_memory_stats
    (VAR jm_mm_stats_ptr: ^ost$jm_mm_stats;
     VAR status: ost$status);

    VAR
      sum_shared: integer,
      i: 0 .. 255,
      siteq_active: 0 .. 255,
      count_p: ^ost$job_and_memory_stats;

    status.normal := TRUE;

    IF jm_mm_stats_ptr = NIL THEN
      ALLOCATE jm_mm_stats_ptr IN osv$task_private_heap^;
      osp$get_jm_mm_stats (FALSE, jm_mm_stats_ptr^, status);
      IF NOT status.normal THEN
        FREE jm_mm_stats_ptr IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    sum_shared := 0;
    siteq_active := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.site_defined_queues_active;
    PUSH count_p: [1 .. osc$jms_shared_last_sys + siteq_active];
    IF siteq_active > 0 THEN
      FOR i := 0 TO siteq_active - 1 DO
        sum_shared := sum_shared + jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
              q_counts [i + mmc$pq_shared_first_site];
        count_p^ [osc$jms_shared_first_site + i] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
              q_counts [i + mmc$pq_shared_first_site];
      FOREND;
    IFEND;
    count_p^ [osc$jms_free_pages] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_free];
    count_p^ [osc$jms_available_pages] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_avail];
    count_p^ [osc$jms_avail_mod_pages] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
          q_counts [mmc$pq_avail_modified];
    count_p^ [osc$jms_wired_pages] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_wired];
    FOR i := 0 TO (osc$jms_shared_last_sys - osc$jms_shared_first) DO
      sum_shared := sum_shared + jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
            q_counts [i + mmc$pq_shared_first];
      count_p^ [osc$jms_shared_first + i] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
            q_counts [i + mmc$pq_shared_first];
    FOREND;
    count_p^ [osc$jms_shared_pages] := sum_shared;
    count_p^ [osc$jms_fixed_pages] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_job_fixed];
    count_p^ [osc$jms_io_error_pages] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
          q_counts [mmc$pq_job_io_error] + jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
          q_counts [mmc$pq_shared_io_error] + jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
          q_counts [mmc$pq_swapped_io_error] + jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
          q_counts [mmc$pq_flawed];
    count_p^ [osc$jms_job_working_set_pages] := jm_mm_stats_ptr^.jm_mm_stats.page_q_counts.
          q_counts [mmc$pq_job_working_set];
    count_p^ [osc$jms_swapped_jobs] := jm_mm_stats_ptr^.jm_mm_stats.total_swapped_jobs;
    count_p^ [osc$jms_ready_tasks] := jm_mm_stats_ptr^.jm_mm_stats.total_ready_tasks;
    count_p^ [osc$jms_total_interactive_jobs] := jm_mm_stats_ptr^.jm_mm_stats.total_interactive_jobs;
    count_p^ [osc$jms_tot_noninteractive_jobs] := jm_mm_stats_ptr^.jm_mm_stats.total_non_interactive_jobs;

    sfp$emit_statistic (osc$job_and_memory_stats, '', count_p, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_job_and_memory_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_paging_and_mtr_stats' ??
?? NEWTITLE := 'OS1' , EJECT ??

  PROCEDURE emit_paging_and_mtr_stats
    (VAR page_fault_stats_ptr: ^ost$page_fault_stats;
     VAR server_page_fault_stats_ptr: ^ost$page_fault_stats;
     VAR aging_stats_ptr: ^ost$aging_stats;
     VAR mtr_reqs_ptr: ^ost$mtr_stats;
     VAR paging_stats_ptr: ^ost$paging_stats;
     VAR status: ost$status);

    VAR
      allocate_pf_ptr: boolean,
      allocate_ps_ptr: boolean,
      allocate_server_pf_ptr: boolean,
      counters: ost$paging_and_mtr_stats,
      cycle_count,
      delay_count,
      wait_count,
      mod_page_count: integer;

    status.normal := TRUE;
    allocate_pf_ptr := FALSE;
    allocate_ps_ptr := FALSE;
    allocate_server_pf_ptr := FALSE;

    IF page_fault_stats_ptr = NIL THEN
      allocate_pf_ptr := TRUE;
      ALLOCATE page_fault_stats_ptr IN osv$task_private_heap^;
    IFEND;
    IF server_page_fault_stats_ptr = NIL THEN
      allocate_server_pf_ptr := TRUE;
      ALLOCATE server_page_fault_stats_ptr IN osv$task_private_heap^;
    IFEND;
    osp$get_page_stats (FALSE, page_fault_stats_ptr^, server_page_fault_stats_ptr^, status);
    IF NOT status.normal THEN
      IF allocate_pf_ptr THEN
        FREE page_fault_stats_ptr IN osv$task_private_heap^;
      IFEND;
      IF allocate_server_pf_ptr THEN
        FREE server_page_fault_stats_ptr IN osv$task_private_heap^;
      IFEND;
      RETURN;
    IFEND;

    IF paging_stats_ptr = NIL THEN
      allocate_ps_ptr := TRUE;
      ALLOCATE paging_stats_ptr IN osv$task_private_heap^;
    IFEND;
    osp$get_paging_stats (FALSE, paging_stats_ptr^, status);
    IF NOT status.normal THEN
      IF allocate_ps_ptr THEN
        FREE paging_stats_ptr IN osv$task_private_heap^;
      IFEND;
      RETURN;
    IFEND;

    IF mtr_reqs_ptr = NIL THEN
      ALLOCATE mtr_reqs_ptr IN osv$task_private_heap^;
      osp$get_mtr_stats (FALSE, mtr_reqs_ptr^, status);
      IF NOT status.normal THEN
        FREE mtr_reqs_ptr IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;
    IF aging_stats_ptr = NIL THEN
      ALLOCATE aging_stats_ptr IN osv$task_private_heap^;
      osp$get_aging_stats (FALSE, aging_stats_ptr^, status);
      IF NOT status.normal THEN
        FREE aging_stats_ptr IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

{ Currently, SERVER page_fault statistics are not kept/emitted (server_page_fault_stats_ptr).

    counters [osc$pms_pf_avail] := page_fault_stats_ptr^.pf_stats [$INTEGER (ps_found_in_avail)];
    counters [osc$pms_pf_avail_mod] := page_fault_stats_ptr^.pf_stats [$INTEGER (ps_found_in_avail_modified)];
    counters [osc$pms_pf_disk_read] := page_fault_stats_ptr^.pf_stats [$INTEGER (ps_found_on_disk)];
    counters [osc$pms_pf_new_page] := page_fault_stats_ptr^.pf_stats [$INTEGER (ps_new_page_assigned)];
    counters [osc$pms_pf_locked] := page_fault_stats_ptr^.pf_stats [$INTEGER (ps_locked)];
    counters [osc$pms_pf_io_reject] := page_fault_stats_ptr^.pf_stats [$INTEGER (ps_io_temp_reject)];

    counters [osc$pms_force_aggr_aging] := aging_stats_ptr^.aging_stats.force_aggressive_aging;
    counters [osc$pms_aggr_age_shared_q] := aging_stats_ptr^.aging_stats.aggressive_age_shared_queue;
    counters [osc$pms_aggr_age_job_q] := aging_stats_ptr^.aging_stats.aggressive_age_job_queues;
    counters [osc$pms_aggr_age_failed] := aging_stats_ptr^.aging_stats.aggressive_aging_failed;
    counters [osc$pms_write_aged_page] := aging_stats_ptr^.aging_stats.page_written_to_disk;

    counters [osc$pms_mr_cycle] := mtr_reqs_ptr^.mtr_reqs [syc$rc_cycle].count;
    cycle_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_cycle].count - previous_cycle_count;
    IF cycle_count = 0 THEN
      counters [osc$pms_mr_cycle_aver_duration] := 0;
    ELSE
      counters [osc$pms_mr_cycle_aver_duration] := (mtr_reqs_ptr^.mtr_reqs [syc$rc_cycle].total_cpu_time -
            previous_cycle_time) DIV (cycle_count);
    IFEND;
    previous_cycle_time := mtr_reqs_ptr^.mtr_reqs [syc$rc_cycle].total_cpu_time;
    previous_cycle_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_cycle].count;
    counters [osc$pms_mr_delay] := mtr_reqs_ptr^.mtr_reqs [syc$rc_delay].count;
    delay_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_delay].count - previous_delay_count;
    IF delay_count = 0 THEN
      counters [osc$pms_mr_delay_aver_duration] := 0;
    ELSE
      counters [osc$pms_mr_delay_aver_duration] := (mtr_reqs_ptr^.mtr_reqs [syc$rc_delay].total_cpu_time -
            previous_delay_time) DIV (delay_count);
    IFEND;
    previous_delay_time := mtr_reqs_ptr^.mtr_reqs [syc$rc_delay].total_cpu_time;
    previous_delay_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_delay].count;
    counters [osc$pms_mr_wait] := mtr_reqs_ptr^.mtr_reqs [syc$rc_wait].count;
    wait_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_wait].count - previous_wait_count;
    IF wait_count = 0 THEN
      counters [osc$pms_mr_wait_aver_duration] := 0;
    ELSE
      counters [osc$pms_mr_wait_aver_duration] := (mtr_reqs_ptr^.mtr_reqs [syc$rc_wait].total_cpu_time -
            previous_wait_time) DIV (wait_count);
    IFEND;
    previous_wait_time := mtr_reqs_ptr^.mtr_reqs [syc$rc_wait].total_cpu_time;
    previous_wait_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_wait].count;
    counters [osc$pms_mr_write_mod_pages] := mtr_reqs_ptr^.mtr_reqs [syc$rc_write_modified_pages].count;
    mod_page_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_write_modified_pages].count -
          previous_write_mod_pages_count;
    IF mod_page_count = 0 THEN
      counters [osc$pms_mr_wmp_aver_duration] := 0;
    ELSE
      counters [osc$pms_mr_wmp_aver_duration] := (mtr_reqs_ptr^.mtr_reqs [syc$rc_write_modified_pages].
            total_cpu_time - previous_write_mod_pages_time) DIV (mod_page_count);

    IFEND;
    previous_write_mod_pages_time := mtr_reqs_ptr^.mtr_reqs [syc$rc_write_modified_pages].total_cpu_time;
    previous_write_mod_pages_count := mtr_reqs_ptr^.mtr_reqs [syc$rc_write_modified_pages].count;

    counters [osc$pms_ps_prestream_initiated] := paging_stats_ptr^.p_stats.page_streaming.prestream_only +
          paging_stats_ptr^.p_stats.page_streaming.initiated;
    counters [osc$pms_ps_initiated] := paging_stats_ptr^.p_stats.page_streaming.initiated;
    counters [osc$pms_ps_prestream_only] := paging_stats_ptr^.p_stats.page_streaming.prestream_only;
    counters [osc$pms_ps_terminated] := paging_stats_ptr^.p_stats.page_streaming.terminated;
    counters [osc$pms_ps_pages_prestream] := paging_stats_ptr^.p_stats.page_streaming.pages_prestream;
    counters [osc$pms_ps_pages_streaming] := paging_stats_ptr^.p_stats.page_streaming.pages_streaming;
    counters [osc$pms_ps_task_slow] := paging_stats_ptr^.p_stats.page_streaming.task_slow;
    counters [osc$pms_ps_pages_faults_tu] := paging_stats_ptr^.p_stats.page_streaming.page_faults_tu;
    counters [osc$pms_ps_pages_freed_behind] := paging_stats_ptr^.p_stats.page_streaming.pages_freed_behind;
    counters [osc$pms_ps_random_faults] := paging_stats_ptr^.p_stats.page_streaming.random_faults;

    sfp$emit_statistic (osc$paging_and_mtr_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_paging_and_mtr_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_pio_statistics' ??
?? NEWTITLE := 'OS2,OS3,OS4,OS5' , EJECT ??

  PROCEDURE emit_pio_statistics
    (    stat_entry: ost$stat_entry;
     VAR pio_pp_stats_p: ^ost$disk_pp_stats;
     VAR pio_unit_stats_p: ^ost$disk_unit_stats;
     VAR pio_disk_space_stats_p: ^ost$disk_space_stats;
     VAR status: ost$status);

    VAR
      disk_space_counters: array [1 .. 1] of integer,
      disk_space_descriptive_data: string (6),
      path_descriptive_data: string (19),
      path_stats_counters: array [1 .. 9] of integer,
      pp_descriptive_data: string (8),
      pp_stats_counters: array [1 .. 6] of integer,
      unit_stats_counters: array [1 .. 24] of integer,
      unit_descriptive_data: string (14);

    VAR
      concurrent_channel: string (1),
      controller_type: string (5),
      equip_index: integer,
      length: integer,
      loop_end: integer,
      loop_start: integer,
      path_usage_record: iot$path_usage,
      port: string (1),
      port_index: integer,
      pp_count: integer,
      pp_index: integer,
      unit_count: integer,
      unit_index: integer,
      unit_type: string (7);

    status.normal := TRUE;

    osp$get_pp_unit_count (pp_count, unit_count, status);
    IF (pp_count = 0) OR (unit_count = 0) THEN
      status.normal := FALSE;
      RETURN;
    IFEND;

    CASE stat_entry.stat OF

    = osc$io_pp_usage, osc$io_path_usage =

      IF pio_pp_stats_p = NIL THEN
        ALLOCATE pio_pp_stats_p: [1 .. pp_count] IN osv$task_private_heap^;
        osp$get_pio_pp_stats (FALSE, pio_pp_stats_p^, status);
        IF NOT status.normal THEN
          FREE pio_pp_stats_p IN osv$task_private_heap^;
          RETURN;
        IFEND;
      IFEND;

      IF stat_entry.first_index <> osc$all_stats THEN
        loop_start := stat_entry.first_index;
        loop_end := stat_entry.second_index;
      ELSE
        loop_start := 1;
        loop_end := pp_count;
      IFEND;

    /pp_loop/
      FOR pp_index := loop_start TO loop_end DO
        IF pio_pp_stats_p^.disk_pp_stats [pp_index].channel.concurrent THEN
          concurrent_channel := '1'
        ELSE
          concurrent_channel := '0'
        IFEND;
        IF stat_entry.stat = osc$io_pp_usage THEN
          pp_stats_counters [1] := pio_pp_stats_p^.disk_pp_stats [pp_index].computed_data_transfer_time;
          pp_stats_counters [2] := pio_pp_stats_p^.disk_pp_stats [pp_index].seek_and_latency_time;
          pp_stats_counters [3] := pio_pp_stats_p^.disk_pp_stats [pp_index].streamed_req_count_read;
          pp_stats_counters [4] := pio_pp_stats_p^.disk_pp_stats [pp_index].streamed_req_failed_count_read;
          pp_stats_counters [5] := pio_pp_stats_p^.disk_pp_stats [pp_index].streamed_req_count_write;
          pp_stats_counters [6] := pio_pp_stats_p^.disk_pp_stats [pp_index].streamed_req_failed_count_write;
          pp_descriptive_data := '';
          STRINGREP (pp_descriptive_data, length, pio_pp_stats_p^.disk_pp_stats [pp_index].iou_number: 2, ',',
                concurrent_channel: 1, ',', pio_pp_stats_p^.disk_pp_stats [pp_index].channel.number: 3);
          sfp$emit_statistic (osc$io_pp_usage, pp_descriptive_data (2, * ), ^pp_stats_counters, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        IFEND;

        IF stat_entry.stat = osc$io_path_usage THEN

        /port_loop/
          FOR port_index := 0 TO 1 DO
            IF pio_pp_stats_p^.disk_pp_stats [pp_index].channel.concurrent THEN
              IF pio_pp_stats_p^.disk_pp_stats [pp_index].channel.port = cmc$unspecified_port THEN
                port := 'U';
              ELSE
                IF port_index = 0 THEN
                  port := 'A';
                ELSE
                  port := 'B';
                IFEND;
              IFEND;
            ELSE
              port := 'N';
            IFEND;

          /equipment_loop/
            FOR equip_index := 0 TO 7 DO
              IF pio_pp_stats_p^.disk_pp_stats [pp_index].path_usage [port_index] [equip_index].path_used THEN
                path_usage_record := pio_pp_stats_p^.disk_pp_stats [pp_index].path_usage [port_index]
                      [equip_index];
                path_stats_counters [1] := path_usage_record.read_requests;
                path_stats_counters [2] := path_usage_record.read_maus * path_usage_record.bytes_per_mau;
                path_stats_counters [3] := path_usage_record.write_requests;
                path_stats_counters [4] := path_usage_record.written_and_preset_maus *
                      path_usage_record.bytes_per_mau;
                path_stats_counters [5] := path_usage_record.total_request_qtime;
                path_stats_counters [6] := path_usage_record.intermediate_errors;
                path_stats_counters [7] := path_usage_record.recovered_errors;
                path_stats_counters [8] := path_usage_record.unrecovered_errors;
                path_stats_counters [9] := path_usage_record.bytes_per_mau;

                CASE path_usage_record.path_type OF
                = cmc$ms7154_x =
                  controller_type := '7154';
                = cmc$ms7155_1, cmc$ms7155_1x =
                  controller_type := '7155';
                = cmc$ms7165_2x =
                  controller_type := '7165';
                = cmc$ms7255_1_1, cmc$ms7255_1_2 =
                  controller_type := '7255';
                = cmc$mscm3_ct =
                  controller_type := 'CM3';
                = cmc$mshydra_ct =
                  controller_type := 'HYDRA';
                = cmc$ms5831_x =
                  controller_type := '5831';
                = cmc$msntdc_1 =
                  controller_type := 'NTDC';
                = cmc$msntdc_2 =
                  controller_type := 'NTD2';
                ELSE
                  controller_type := '     ';
                CASEND;

                STRINGREP (path_descriptive_data, length, pio_pp_stats_p^.disk_pp_stats [pp_index].
                      iou_number: 2, ',', concurrent_channel: 1, ',', pio_pp_stats_p^.
                      disk_pp_stats [pp_index].channel.number: 3, ',', port: 1, ',', equip_index: 2, ',',
                      controller_type: 5);

                sfp$emit_statistic (osc$io_path_usage, path_descriptive_data (2, * ), ^path_stats_counters,
                      status);
                IF NOT status.normal THEN
                  RETURN;
                IFEND;
              IFEND;
            FOREND /equipment_loop/;
          FOREND /port_loop/;
        IFEND;
      FOREND /pp_loop/;

    = osc$io_unit_usage =

      IF pio_unit_stats_p = NIL THEN
        ALLOCATE pio_unit_stats_p: [1 .. unit_count] IN osv$task_private_heap^;
        osp$get_pio_unit_stats (FALSE, pio_unit_stats_p^, status);
        IF NOT status.normal THEN
          FREE pio_unit_stats_p IN osv$task_private_heap^;
          RETURN;
        IFEND;
      IFEND;

      IF stat_entry.first_index <> osc$all_stats THEN
        loop_start := stat_entry.first_index;
        loop_end := stat_entry.second_index;
      ELSE
        loop_start := 1;
        loop_end := unit_count;
      IFEND;

    /unit_loop/
      FOR unit_index := loop_start TO loop_end DO
        IF (pio_unit_stats_p^.disk_unit_stats [unit_index].unit_used) THEN
          unit_stats_counters [1] := pio_unit_stats_p^.disk_unit_stats [unit_index].read_requests;
          unit_stats_counters [2] := pio_unit_stats_p^.disk_unit_stats [unit_index].read_qtime;
          unit_stats_counters [3] := pio_unit_stats_p^.disk_unit_stats [unit_index].read_mau_count *
                pio_unit_stats_p^.disk_unit_stats [unit_index].bytes_per_mau;
          unit_stats_counters [4] := pio_unit_stats_p^.disk_unit_stats [unit_index].write_requests;
          unit_stats_counters [5] := pio_unit_stats_p^.disk_unit_stats [unit_index].write_qtime;
          unit_stats_counters [6] := pio_unit_stats_p^.disk_unit_stats [unit_index].write_data_mau_count *
                pio_unit_stats_p^.disk_unit_stats [unit_index].bytes_per_mau;
          unit_stats_counters [7] := pio_unit_stats_p^.disk_unit_stats [unit_index].
                write_data_and_preset_maus * pio_unit_stats_p^.disk_unit_stats [unit_index].bytes_per_mau;
          unit_stats_counters [8] := pio_unit_stats_p^.disk_unit_stats [unit_index].swap_in_requests;
          unit_stats_counters [9] := pio_unit_stats_p^.disk_unit_stats [unit_index].swap_in_qtime;
          unit_stats_counters [10] := pio_unit_stats_p^.disk_unit_stats [unit_index].swap_in_mau_count *
                pio_unit_stats_p^.disk_unit_stats [unit_index].bytes_per_mau;
          unit_stats_counters [11] := pio_unit_stats_p^.disk_unit_stats [unit_index].swap_out_requests;
          unit_stats_counters [12] := pio_unit_stats_p^.disk_unit_stats [unit_index].swap_out_qtime;
          unit_stats_counters [13] := pio_unit_stats_p^.disk_unit_stats [unit_index].swap_out_data_mau_count *
                pio_unit_stats_p^.disk_unit_stats [unit_index].bytes_per_mau;
          unit_stats_counters [14] := pio_unit_stats_p^.disk_unit_stats [unit_index].
                swap_out_data_and_preset_maus * pio_unit_stats_p^.disk_unit_stats [unit_index].bytes_per_mau;
          unit_stats_counters [15] := pio_unit_stats_p^.disk_unit_stats [unit_index].streamed_req_count_read;
          unit_stats_counters [16] := pio_unit_stats_p^.disk_unit_stats [unit_index].
                streamed_req_failed_count_read;
          unit_stats_counters [17] := pio_unit_stats_p^.disk_unit_stats [unit_index].streamed_req_count_write;
          unit_stats_counters [18] := pio_unit_stats_p^.disk_unit_stats [unit_index].
                streamed_req_failed_count_write;
          unit_stats_counters [19] := pio_unit_stats_p^.disk_unit_stats [unit_index].
                requests_causing_skipped_cyl;
          unit_stats_counters [20] := pio_unit_stats_p^.disk_unit_stats [unit_index].total_cylinders_skipped;
          unit_stats_counters [21] := pio_unit_stats_p^.disk_unit_stats [unit_index].intermediate_errors;
          unit_stats_counters [22] := pio_unit_stats_p^.disk_unit_stats [unit_index].recovered_errors;
          unit_stats_counters [23] := pio_unit_stats_p^.disk_unit_stats [unit_index].unrecovered_errors;
          unit_stats_counters [24] := pio_unit_stats_p^.disk_unit_stats [unit_index].bytes_per_mau;

          CASE pio_unit_stats_p^.disk_unit_stats [unit_index].unit_type OF
          = ioc$dt_ms844_4x =
            unit_type := '  844';
          = ioc$dt_ms885_1x, ioc$dt_ms885_42 =
            unit_type := '  885';
          = ioc$dt_ms834_2 =
            unit_type := '  834';
          = ioc$dt_msfsd_2 =
            unit_type := '  FSD';
          = ioc$dt_ms895_2 =
            unit_type := '  895';
          = ioc$dt_mshydra =
            unit_type := '  887';
          = ioc$dt_ms9836_1 =
            unit_type := ' 9836';
          = ioc$dt_msxmd_3 =
            unit_type := ' 9853';
          = ioc$dt_ms5832_1 =
            unit_type := '5832_1';
          = ioc$dt_ms5832_2 =
            unit_type := '5832_2';
          = ioc$dt_ms5833_1 =
            unit_type := '5833_1';
          = ioc$dt_ms5833_1p =
            unit_type := '5833_1P';
          = ioc$dt_ms5833_2 =
            unit_type := '5833_2';
          = ioc$dt_ms5833_3p =
            unit_type := '5833_3P';
          = ioc$dt_ms5833_4 =
            unit_type := '5833_4';
          = ioc$dt_ms5837_1 =
            unit_type := '5837_1';
          = ioc$dt_ms5837_1p =
            unit_type := '5837_1P';
          = ioc$dt_ms5837_2 =
            unit_type := '5837_2';
          = ioc$dt_ms5837_3p =
            unit_type := '5837_3P';
          = ioc$dt_ms5837_4 =
            unit_type := '5837_4';
          = ioc$dt_ms5838_1 =
            unit_type := '5838_1';
          = ioc$dt_ms5838_1p =
            unit_type := '5838_1P';
          = ioc$dt_ms5838_2 =
            unit_type := '5838_2';
          = ioc$dt_ms5838_3p =
            unit_type := '5838_3P';
          = ioc$dt_ms5838_4 =
            unit_type := '5838_4';
          = ioc$dt_ms47444_1 =
            unit_type := '47444_1';
          = ioc$dt_ms47444_1p =
            unit_type := '47444_1P';
          = ioc$dt_ms47444_2 =
            unit_type := '47444_2';
          = ioc$dt_ms47444_3p =
            unit_type := '47444_3P';
          = ioc$dt_ms47444_4 =
            unit_type := '47444_4';
          = ioc$dt_msntdd_1 =
            unit_type := 'NTDD_1';
          = ioc$dt_msntdd_2 =
            unit_type := 'NTDD_2';
          = ioc$dt_msntdd_3 =
            unit_type := 'NTDD_3';
          = ioc$dt_msntdd_4 =
            unit_type := 'NTDD_4';
          = ioc$dt_msntdd_5 =
            unit_type := 'NTDD_5';
          = ioc$dt_msntdd_6 =
            unit_type := 'NTDD_6';
          ELSE
            unit_type := '    ';
          CASEND;

          STRINGREP (unit_descriptive_data, length, pio_unit_stats_p^.disk_unit_stats [unit_index].
                recorded_vsn: 6, ',', unit_type: 7);

          sfp$emit_statistic (osc$io_unit_usage, unit_descriptive_data, ^unit_stats_counters, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        IFEND;
      FOREND /unit_loop/;

    = osc$io_disk_space =

      IF pio_disk_space_stats_p = NIL THEN
        ALLOCATE pio_disk_space_stats_p: [1 .. unit_count] IN osv$task_private_heap^;
        pmp$zero_out_table (#LOC (pio_disk_space_stats_p^), #SIZE (pio_disk_space_stats_p^));
        osp$get_disk_space_stats (pio_disk_space_stats_p^);
      IFEND;

      IF stat_entry.first_index <> osc$all_stats THEN
        loop_start := stat_entry.first_index;
        loop_end := stat_entry.second_index;
      ELSE
        loop_start := 1;
        loop_end := unit_count;
      IFEND;

      FOR unit_index := loop_start TO loop_end DO
        IF pio_disk_space_stats_p^.disk_space [unit_index].unit_used THEN
          STRINGREP (disk_space_descriptive_data, length, pio_disk_space_stats_p^.disk_space [unit_index].
                recorded_vsn: 6);
          disk_space_counters [1] := pio_disk_space_stats_p^.disk_space [unit_index].available_space;
          sfp$emit_statistic (osc$io_disk_space, disk_space_descriptive_data, ^disk_space_counters, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        IFEND;
      FOREND;

    ELSE

    CASEND;

  PROCEND emit_pio_statistics;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_cpu_statistics' ??
?? NEWTITLE := 'OS6' , EJECT ??

{ Statistic OS6 is a periodic statistic that contains a summary of the total CPU usage.

  PROCEDURE emit_cpu_statistics
    (VAR cpu_stats_p: ^ost$cpu_stats;
     VAR mtr_reqs_p: ^ost$mtr_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 15] of integer,
      cpu: integer,
      descriptive_data: string (10),
      dp: integer;

    status.normal := TRUE;

    IF cpu_stats_p = NIL THEN
      ALLOCATE cpu_stats_p IN osv$task_private_heap^;
      osp$get_cpu_stats (FALSE, cpu_stats_p^, status);
      IF NOT status.normal THEN
        FREE cpu_stats_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    IF mtr_reqs_p = NIL THEN
      ALLOCATE mtr_reqs_p IN osv$task_private_heap^;
      osp$get_mtr_stats (FALSE, mtr_reqs_p^, status);
      IF NOT status.normal THEN
        FREE mtr_reqs_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;


    counters [1] := 0;
    counters [2] := 0;
    counters [10] := 0;
    counters [11] := 0;
    counters [12] := 0;
    counters [13] := 0;
    counters [14] := 0;
    FOR cpu := 0 TO cpu_stats_p^.cpu_stats.cpu_count DO
      IF (cpu_stats_p^.cpu_stats.processor_defined [cpu]) THEN

{  Compute total idle time for all cpus

        counters [1] := counters [1] + cpu_stats_p^.cpu_stats.idle_stats [cpu].idle_no_io_active;
        counters [2] := counters [2] + cpu_stats_p^.cpu_stats.idle_stats [cpu].idle_io_active;

{  Report idle time for individual cpus .
{  Counters 11 and 12 report idle time for CP0 and counters 13 and 14 report idle time for CP1.

        CASE cpu OF
        = 0 =
          counters [11] := cpu_stats_p^.cpu_stats.idle_stats [cpu].idle_no_io_active;
          counters [12] := cpu_stats_p^.cpu_stats.idle_stats [cpu].idle_io_active;
        = 1 =
          counters [13] := cpu_stats_p^.cpu_stats.idle_stats [cpu].idle_no_io_active;
          counters [14] := cpu_stats_p^.cpu_stats.idle_stats [cpu].idle_io_active;
        ELSE  { not reported for more than 2 cpus}
        CASEND;

{  Increment number of cpus.

        counters [10] := counters [10] + 1;
      IFEND;
    FOREND;

    counters [3] := 0;
    counters [4] := 0;
    FOR dp := jmc$max_dispatching_priority DOWNTO jmc$min_dispatching_priority DO
      counters [3] := counters [3] + cpu_stats_p^.cpu_stats.cpu_execution_stats [dp].time_spent_in_job_mode;
      counters [4] := counters [4] + cpu_stats_p^.cpu_stats.cpu_execution_stats [dp].time_spent_in_mtr_mode;
    FOREND;

    IF cpu_stats_p^.cpu_stats.nos_stats.nos_on THEN
      counters [5] := cpu_stats_p^.cpu_stats.nos_stats.nos_time;
      counters [6] := cpu_stats_p^.cpu_stats.nos_stats.nos_time_ve_idle;
    ELSE
      counters [5] := 0;
      counters [6] := 0;
    IFEND;

    counters [7] := osv$monitor_interlock_wait_time.time;
    counters [8] := mtr_reqs_p^.mtr_reqs[syc$rc_switch_task].count;
    counters [9] := 0; {future - need queue length}
    counters [15] := mtr_reqs_p^.mtr_reqs[syc$rc_process_due].total_cpu_time +           {PROCESS_DUE}
                     mtr_reqs_p^.mtr_reqs[syc$rc_process_dft_block].total_cpu_time +     {PROCESS_DFT_ENTRY}
                     mtr_reqs_p^.mtr_reqs[syc$rc_swap_job].total_cpu_time +              {MONITOR_SWAP_REQS}
                     mtr_reqs_p^.mtr_reqs[syc$rc_periodic_call].total_cpu_time +         {PERIODIC_CALL}
                     mtr_reqs_p^.mtr_reqs[syc$rc_process_scd_block].total_cpu_time +     {PROCESS_SCD_BLOC}
                     mtr_reqs_p^.mtr_reqs[syc$rc_process_io_completions].total_cpu_time +{PROCESS_IO}
                     mtr_reqs_p^.mtr_reqs[syc$rc_monitor_system_status].total_cpu_time + {MONITOR_SYS_STATUS}
                     mtr_reqs_p^.mtr_reqs[syc$rc_switch_task].total_cpu_time;            {SWITCH_TASK}

    sfp$emit_statistic (osc$cpu_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_cpu_statistics;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_service_class_stats' ??
?? NEWTITLE := 'OS7', EJECT ??

{ PURPOSE:
{   Emit the OS7 statistic.

  PROCEDURE emit_service_class_stats
    (VAR status: ost$status);

    VAR
      counters: array [1 .. 18] of integer,
      service_class: jmt$service_class_index,
      service_class_stats_p: ^ost$service_class_stats;

    status.normal := TRUE;

    PUSH service_class_stats_p: [1 .. jmv$max_service_class_in_use];
    pmp$zero_out_table (service_class_stats_p, #SIZE (service_class_stats_p^));
    osp$get_service_class_stats (FALSE, service_class_stats_p^, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    FOR service_class := jmc$system_service_class TO UPPERBOUND (service_class_stats_p^.service_class_stats)
          DO
      IF (jmv$service_classes [service_class] <> NIL) AND jmv$service_classes [service_class]^.attributes.
            defined THEN
        counters [1] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.cp_time.job_mode;
        counters [2] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.cp_time.
              monitor_mode;
        counters [3] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.page_faults.
              disk + service_class_stats_p^.service_class_stats [service_class].mtr_stats.page_faults.
              reclaimed + service_class_stats_p^.service_class_stats [service_class].mtr_stats.page_faults.
              assigned;
        counters [4] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.page_faults.disk;
        counters [5] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.page_faults.
              reclaimed;
        counters [6] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.page_faults.
              assigned;
        counters [7] := service_class_stats_p^.service_class_stats [service_class].sched_stats.active_jobs;
        counters [8] := service_class_stats_p^.service_class_stats [service_class].sched_stats.
              swapin_queue_size;
        counters [9] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              long_wait_swaps;
        counters [10] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              job_mode_swaps;
        counters [11] := service_class_stats_p^.service_class_stats [service_class].sched_stats.memory_waits;
        counters [12] := service_class_stats_p^.service_class_stats [service_class].sched_stats.ajl_waits;
        counters [13] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              swapped_pages;
        counters [14] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              residence_time;
        counters [15] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              swap_wait_time;
        counters [16] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              scheduler_swapins;
        counters [17] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              swap_to_ready_time;
        counters [18] := service_class_stats_p^.service_class_stats [service_class].mtr_stats.swap_stats.
              swap_to_ready_count;

        sfp$emit_statistic (osc$service_class_stats, service_class_stats_p^.
              service_class_stats [service_class].name (1, clp$trimmed_string_size
              (service_class_stats_p^.service_class_stats [service_class].name)), ^counters, status);

        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;
    FOREND;

  PROCEND emit_service_class_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_job_class_stats' ??
?? NEWTITLE := 'OS8', EJECT ??

{ PURPOSE:
{   Emit the OS8 statistic.

  PROCEDURE emit_job_class_stats
    (VAR status: ost$status);

    VAR
      counters: array [1 .. 2] of integer,
      job_class: jmt$job_class,
      job_class_stats_p: ^ost$job_class_stats;

    status.normal := TRUE;

    PUSH job_class_stats_p: [1 .. jmv$maximum_job_class_in_use];
    pmp$zero_out_table (job_class_stats_p, #SIZE (job_class_stats_p^));
    osp$get_job_class_stats (FALSE, job_class_stats_p^, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    FOR job_class := 1 TO UPPERBOUND (job_class_stats_p^.job_class_stats) DO
      IF jmv$job_class_table_p^ [job_class].defined THEN
        counters [1] := job_class_stats_p^.job_class_stats [job_class].job_class_counters.queued_jobs;
        counters [2] := job_class_stats_p^.job_class_stats [job_class].job_class_counters.completed_jobs;

        sfp$emit_statistic (osc$job_class_stats, job_class_stats_p^.job_class_stats [job_class].
              job_class_names.name (1, clp$trimmed_string_size
              (job_class_stats_p^.job_class_stats [job_class].job_class_names.name)), ^counters, status);

        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;
    FOREND;

  PROCEND emit_job_class_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_system_job_stats' ??
?? NEWTITLE := 'OS9' , EJECT ??

{ PURPOSE:
{   Emit the OS9 statistic.

  PROCEDURE emit_system_job_stats
    (VAR system_job_stats_p: ^ost$job_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 11] of integer;

    status.normal := TRUE;

    IF system_job_stats_p = NIL THEN
      ALLOCATE system_job_stats_p IN osv$task_private_heap^;
      osp$get_job_stats (FALSE, system_job_stats_p^, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    IFEND;

    counters [1] := system_job_stats_p^.job_data.cp_time.time_spent_in_job_mode;
    counters [2] := system_job_stats_p^.job_data.cp_time.time_spent_in_mtr_mode;
    counters [3] := system_job_stats_p^.job_data.paging_statistics.page_fault_count;
    counters [4] := system_job_stats_p^.job_data.paging_statistics.page_in_count;
    counters [5] := system_job_stats_p^.job_data.paging_statistics.pages_reclaimed_from_queue;
    counters [6] := system_job_stats_p^.job_data.paging_statistics.new_pages_assigned;
    counters [7] := system_job_stats_p^.job_data.paging_statistics.working_set_max_used;
    counters [8] := system_job_stats_p^.job_data.paging_statistics.pages_from_server;
    counters [9] := system_job_stats_p^.job_data.working_set_size;
    counters [10] := 0; {Will be used in the future for average working set}
    counters [11] := system_job_stats_p^.job_data.ready_task_count;

    sfp$emit_statistic (osc$system_job_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_system_job_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_system_task_stats' ??
?? NEWTITLE := 'OS10' , EJECT ??

{ PURPOSE:
{   Emit the OS10 statistic.

  PROCEDURE emit_system_task_stats
    (VAR system_task_stats_p: ^ost$task_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 3] of integer,
      descriptive_data: string (31),
      task: 0 .. pmc$max_task_id;

    status.normal := TRUE;

    IF system_task_stats_p = NIL THEN
      ALLOCATE system_task_stats_p: [1 .. 100] IN osv$task_private_heap^;
      pmp$collect_raw_task_statistics (system_task_stats_p^.active_task_count,
            system_task_stats_p^.active_task_statistics);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      IF system_task_stats_p^.active_task_count > 100 THEN
        FREE system_task_stats_p IN osv$task_private_heap^;
        ALLOCATE system_task_stats_p: [1 .. system_task_stats_p^.active_task_count] IN osv$task_private_heap^;
        pmp$collect_raw_task_statistics (system_task_stats_p^.active_task_count,
              system_task_stats_p^.active_task_statistics);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;
    IFEND;

    FOR task := 1 TO system_task_stats_p^.active_task_count DO
      counters [1] := system_task_stats_p^.active_task_statistics [task].cp_time.task_time;
      counters [2] := system_task_stats_p^.active_task_statistics [task].cp_time.monitor_time;
      counters [3] := system_task_stats_p^.active_task_statistics [task].page_fault_count;
      descriptive_data := '';
      descriptive_data := system_task_stats_p^.active_task_statistics [task].task_name;
      sfp$emit_statistic (osc$system_task_stats, descriptive_data, ^counters, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    FOREND;

  PROCEND emit_system_task_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_memory_stats' ??
?? NEWTITLE := 'OS11' , EJECT ??

{ PURPOSE:
{   Emit the OS11 statistic.

  PROCEDURE emit_memory_stats
    (VAR jm_mm_stats_p: ^ost$jm_mm_stats;
     VAR status: ost$status);

    VAR
      available_memory: integer,
      counters: array [1 .. 22] of integer,
      descriptive_data: string (31),
      maximum_180_memory: string (18),
      memory_index: integer,
      queue_id: mmt$page_frame_queue_id,
      sum_of_site_shared_queues: integer,
      sum_of_system_shared_queues: integer;

    status.normal := TRUE;

    IF jm_mm_stats_p = NIL THEN
      ALLOCATE jm_mm_stats_p IN osv$task_private_heap^;
      osp$get_jm_mm_stats (FALSE, jm_mm_stats_p^, status);
      IF NOT status.normal THEN
        FREE jm_mm_stats_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    maximum_180_memory := 'MAXIMUM_180_MEMORY';
    osp$fetch_system_constant (maximum_180_memory, memory_index, available_memory, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    counters [1] := available_memory;
    counters [2] := 512 * (128 - #READ_REGISTER (osc$pr_page_size_mask));
    counters [3] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_free];
    counters [4] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_avail];
    counters [5] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_avail_modified];
    counters [6] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_wired];

    sum_of_site_shared_queues := 0;
    FOR queue_id := mmc$pq_shared_first_site TO mmc$pq_shared_last_site DO
      sum_of_site_shared_queues := sum_of_site_shared_queues +
          jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [queue_id];
    FOREND;

    sum_of_system_shared_queues := 0;
    FOR queue_id := mmc$pq_shared_first TO mmc$pq_shared_last DO
      sum_of_system_shared_queues := sum_of_system_shared_queues +
            jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [queue_id];
    FOREND;

    counters [7] := sum_of_system_shared_queues + sum_of_site_shared_queues;
    counters [8] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_shared_io_error];
    counters [9] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_swapped_io_error];
    counters [10] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_job_fixed];
    counters [11] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_job_io_error];
    counters [12] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_job_working_set];
    counters [13] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.swap_resident_count;
    counters [14] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.long_wait_count;
    counters [15] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_shared_task_service];
    counters [16] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_shared_pf_execute];
    counters [17] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_shared_pf_non_execute];
    counters [18] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_shared_device_file];
    counters [19] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_shared_file_server];
    counters [20] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_shared_other];
    counters [21] := sum_of_site_shared_queues;
    counters [22] := jm_mm_stats_p^.jm_mm_stats.page_q_counts.q_counts [mmc$pq_flawed];

    sfp$emit_statistic (osc$memory_utilization_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_memory_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_job_count_stats' ??
?? NEWTITLE := 'OS12' , EJECT ??

{ PURPOSE:
{   Emit the OS12 statistic.

  PROCEDURE emit_job_count_stats
    (VAR jm_mm_stats_p: ^ost$jm_mm_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 5] of integer;

    status.normal := TRUE;

    IF jm_mm_stats_p = NIL THEN
      ALLOCATE jm_mm_stats_p IN osv$task_private_heap^;
      osp$get_jm_mm_stats (FALSE, jm_mm_stats_p^, status);
      IF NOT status.normal THEN
        FREE jm_mm_stats_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    counters [1] := jm_mm_stats_p^.jm_mm_stats.total_system_class;
    counters [2] := jm_mm_stats_p^.jm_mm_stats.total_interactive_jobs;
    counters [3] := jm_mm_stats_p^.jm_mm_stats.total_non_interactive_jobs -
          jm_mm_stats_p^.jm_mm_stats.total_system_class;
    counters [4] := jm_mm_stats_p^.jm_mm_stats.total_active_jobs;
    counters [5] := jm_mm_stats_p^.jm_mm_stats.total_swapped_jobs;

    sfp$emit_statistic (osc$job_count_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_job_count_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_page_streaming_stats' ??
?? NEWTITLE := 'OS13' , EJECT ??

{ PURPOSE:
{   Emit the OS13 statistic.

  PROCEDURE emit_page_streaming_stats
    (VAR paging_stats_p: ^ost$paging_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 11] of integer;

    status.normal := TRUE;

    IF paging_stats_p = NIL THEN
      ALLOCATE paging_stats_p IN osv$task_private_heap^;
      osp$get_paging_stats (FALSE, paging_stats_p^, status);
      IF NOT status.normal THEN
        FREE paging_stats_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    counters [1] := paging_stats_p^.p_stats.page_streaming.prestream_only +
          paging_stats_p^.p_stats.page_streaming.initiated;
    counters [2] := paging_stats_p^.p_stats.page_streaming.initiated;
    counters [3] := paging_stats_p^.p_stats.page_streaming.terminated;
    counters [4] := paging_stats_p^.p_stats.page_streaming.pages_prestream;
    counters [5] := paging_stats_p^.p_stats.page_streaming.pages_streaming;
    counters [6] := paging_stats_p^.p_stats.page_streaming.task_slow;
    counters [7] := paging_stats_p^.p_stats.page_streaming.random_faults;
    counters [8] := 0; {future will contain number of sequential page faults}
    counters [9] := 0; {future will contain number of random page faults}
    counters [10] := 0; {future will contain number of non-random page faults}
    counters [11] := 0; {future will contain number of page faults for tu=0}

    sfp$emit_statistic (osc$page_streaming_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_page_streaming_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_system_mr_stats' ??
?? NEWTITLE := 'OS14' , EJECT ??

{ PURPOSE:
{   Emit the OS14 statistic.

  PROCEDURE emit_system_mr_stats
    (VAR mtr_reqs_p: ^ost$mtr_stats;
     VAR status: ost$status);

    VAR
      index: integer,
      counters: array [1 .. 21] of integer;

    status.normal := TRUE;

    IF mtr_reqs_p = NIL THEN
      ALLOCATE mtr_reqs_p IN osv$task_private_heap^;
      osp$get_mtr_stats (FALSE, mtr_reqs_p^, status);
      IF NOT status.normal THEN
        FREE mtr_reqs_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    counters [1] := mtr_reqs_p^.mtr_reqs [syc$rc_cycle].count;
    counters [2] := mtr_reqs_p^.mtr_reqs [syc$rc_cycle].total_cpu_time;
    counters [3] := mtr_reqs_p^.mtr_reqs [syc$rc_cycle].max_time;
    counters [4] := mtr_reqs_p^.mtr_reqs [syc$rc_delay].count;
    counters [5] := mtr_reqs_p^.mtr_reqs [syc$rc_delay].total_cpu_time;
    counters [6] := mtr_reqs_p^.mtr_reqs [syc$rc_delay].max_time;
    counters [7] := mtr_reqs_p^.mtr_reqs [syc$rc_wait].count;
    counters [8] := mtr_reqs_p^.mtr_reqs [syc$rc_wait].total_cpu_time;
    counters [9] := mtr_reqs_p^.mtr_reqs [syc$rc_wait].max_time;
    counters [10] := mtr_reqs_p^.mtr_reqs [syc$rc_switch_task].count;
    counters [11] := mtr_reqs_p^.mtr_reqs [syc$rc_switch_task].total_cpu_time;
    counters [12] := mtr_reqs_p^.mtr_reqs [syc$rc_switch_task].max_time;
    counters [13] := mtr_reqs_p^.mtr_reqs [syc$rc_process_io_completions].count;
    counters [14] := mtr_reqs_p^.mtr_reqs [syc$rc_process_io_completions].total_cpu_time;
    counters [15] := mtr_reqs_p^.mtr_reqs [syc$rc_process_io_completions].max_time;
    counters [16] := mtr_reqs_p^.mtr_reqs [syc$rc_periodic_call].count;
    counters [17] := mtr_reqs_p^.mtr_reqs [syc$rc_periodic_call].total_cpu_time;
    counters [18] := mtr_reqs_p^.mtr_reqs [syc$rc_periodic_call].max_time;
    counters [19] := mtr_reqs_p^.mtr_reqs [syc$rc_ready_task].count;
    counters [20] := mtr_reqs_p^.mtr_reqs [syc$rc_ready_task].total_cpu_time;
    counters [21] := mtr_reqs_p^.mtr_reqs [syc$rc_ready_task].max_time;

    sfp$emit_statistic (osc$monitor_request_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_system_mr_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_cpu_dispatching_stats' ??
?? NEWTITLE := 'OS15' , EJECT ??

{ PURPOSE:
{   Emit the OS15 statistic.

  PROCEDURE emit_cpu_dispatching_stats
    (VAR cpu_stats_p: ^ost$cpu_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 2*(jmc$max_dispatching_priority - 1)] of integer,
      dp: jmc$min_dispatching_priority .. jmc$max_dispatching_priority ,
      index: 1 .. 2*jmc$max_dispatching_priority ;

    status.normal := TRUE;

    IF cpu_stats_p = NIL THEN
      ALLOCATE cpu_stats_p IN osv$task_private_heap^;
      osp$get_cpu_stats (FALSE, cpu_stats_p^, status);
      IF NOT status.normal THEN
        FREE cpu_stats_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

{ Jmc$min_dispatching_priority equals 2 and corresponds to P1.
{ Jmc$max_dispatching_priority equals 15 and corresponds to P14.
{ Two counters are calculated for each dispatching priority so that a total of
{ 28 counters are emitted with the statistic.

    index := 1;
    FOR dp := jmc$min_dispatching_priority TO jmc$max_dispatching_priority DO
      counters [index] := cpu_stats_p^.cpu_stats.cpu_execution_stats [dp].time_spent_in_job_mode;
      counters [index + 1] := cpu_stats_p^.cpu_stats.cpu_execution_stats [dp].time_spent_in_mtr_mode;
      index := index + 2;
    FOREND;

    sfp$emit_statistic (osc$cpu_dispatching_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_cpu_dispatching_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_page_faults_rejected_stats' ??
?? NEWTITLE := 'OS16' , EJECT ??

{ PURPOSE:
{   Emit the OS16 statistic.

  PROCEDURE emit_page_fault_rejected_stats
    (VAR page_fault_stats_p: ^ost$page_fault_stats;
     VAR server_page_fault_stats_p: ^ost$page_fault_stats;
     VAR status: ost$status);

    VAR
      allocate_pf_ptr: boolean,
      allocate_server_pf_ptr: boolean,
      counters: array [1 .. 11] of integer;

    status.normal := TRUE;
    allocate_pf_ptr := FALSE;
    allocate_server_pf_ptr := FALSE;

    IF page_fault_stats_p = NIL THEN
      allocate_pf_ptr := TRUE;
      ALLOCATE page_fault_stats_p IN osv$task_private_heap^;
    IFEND;
    IF server_page_fault_stats_p = NIL THEN
      allocate_server_pf_ptr := TRUE;
      ALLOCATE server_page_fault_stats_p IN osv$task_private_heap^;
    IFEND;
    osp$get_page_stats (FALSE, page_fault_stats_p^, server_page_fault_stats_p^, status);
    IF NOT status.normal THEN
      IF allocate_pf_ptr THEN
        FREE page_fault_stats_p IN osv$task_private_heap^;
      IFEND;
      IF allocate_server_pf_ptr THEN
        FREE server_page_fault_stats_p IN osv$task_private_heap^;
      IFEND;
      RETURN;
    IFEND;

    counters [1] := page_fault_stats_p^.pf_stats [$INTEGER (ps_no_memory)];
    counters [2] := page_fault_stats_p^.pf_stats [$INTEGER (ps_low_on_memory)];
    counters [3] := page_fault_stats_p^.pf_stats [$INTEGER (ps_locked)];
    counters [4] := page_fault_stats_p^.pf_stats [$INTEGER (ps_pt_full)];
    counters [5] := page_fault_stats_p^.pf_stats [$INTEGER (ps_io_temp_reject)];
    counters [6] := page_fault_stats_p^.pf_stats [$INTEGER (ps_beyond_file_limit)];
    counters [7] := page_fault_stats_p^.pf_stats [$INTEGER (ps_read_beyond_eoi)];
    counters [8] := page_fault_stats_p^.pf_stats [$INTEGER (ps_no_extend_permission)];
    counters [9] := page_fault_stats_p^.pf_stats [$INTEGER (ps_volume_unavailable)];
    counters [10] := page_fault_stats_p^.pf_stats [$INTEGER (ps_allocate_required_on_server)];
    counters [11] := page_fault_stats_p^.pf_stats [$INTEGER (ps_server_terminated)];

    sfp$emit_statistic (osc$page_fault_rejected_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_page_fault_rejected_stats;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_system_job_stats_hide' ??
?? NEWTITLE := 'OS9005', EJECT ??

  PROCEDURE emit_system_job_stats_hide
    (VAR status: ost$status);

    VAR
      counters: array [1 .. 9] of integer,
      job_data: ost$job_stats;

    status.normal := TRUE;
    osp$get_job_stats (FALSE, job_data, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    counters [1] := job_data.job_data.cp_time.time_spent_in_job_mode;
    counters [2] := job_data.job_data.cp_time.time_spent_in_mtr_mode;
    counters [3] := job_data.job_data.paging_statistics.page_in_count;
    counters [4] := job_data.job_data.paging_statistics.pages_reclaimed_from_queue;
    counters [5] := job_data.job_data.paging_statistics.new_pages_assigned;
    counters [6] := job_data.job_data.working_set_size;
    counters [7] := job_data.job_data.ready_task_count;
    counters [8] := job_data.job_data.paging_statistics.pages_from_server;
    counters [9] := job_data.job_data.paging_statistics.page_fault_count;

    sfp$emit_statistic (osc$system_job_stats_hide  , '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_system_job_stats_hide;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_swap_statistics' ??
?? NEWTITLE := 'OS9007,OS9008' , EJECT ??

  PROCEDURE emit_swap_statistics
    (    stat_entry: ost$stat_entry;
     VAR swap_stats_ptr: ^ost$swap_stats;
     VAR status: ost$status);

    VAR
      from_state,
      to_state: jmt$ijl_swap_status,
      loop_1_start: jmt$ijl_swap_status,
      loop_1_end: jmt$ijl_swap_status,
      loop_2_start: jmt$ijl_swap_status,
      loop_2_end: jmt$ijl_swap_status,
      counters: array [1 .. 3] of integer,
      counterp: array [1 .. 4] of integer,
      descriptive_data: string (10),
      length: integer;

    status.normal := TRUE;

    IF swap_stats_ptr = NIL THEN
      ALLOCATE swap_stats_ptr IN osv$task_private_heap^;
      osp$get_swap_stats (FALSE, swap_stats_ptr^, status);
      IF NOT status.normal THEN
        FREE swap_stats_ptr IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    IF stat_entry.stat = osc$swap_state_stats THEN
      IF stat_entry.from_index <> jmc$iss_null THEN
        loop_1_start := stat_entry.from_index;
        loop_1_end := loop_1_start;
        loop_2_start := stat_entry.to_index;
        loop_2_end := loop_2_start;
      ELSE
        loop_1_start := LOWERVALUE (jmt$ijl_swap_status);
        loop_1_end := UPPERVALUE (jmt$ijl_swap_status);
        loop_2_start := LOWERVALUE (jmt$ijl_swap_status);
        loop_2_end := UPPERVALUE (jmt$ijl_swap_status);
      IFEND;

      FOR from_state := loop_1_start TO loop_1_end DO
        FOR to_state := loop_2_start TO loop_2_end DO

          IF (swap_stats_ptr^.swap_stats [from_state] [to_state].count > 0) OR
                (stat_entry.from_index <> jmc$iss_null) THEN
            counters [1] := swap_stats_ptr^.swap_stats [from_state] [to_state].total_time;
            counters [2] := swap_stats_ptr^.swap_stats [from_state] [to_state].maximum_time;
            counters [3] := swap_stats_ptr^.swap_stats [from_state] [to_state].count;

            descriptive_data := '';
            STRINGREP (descriptive_data, length, $INTEGER (from_state), '  ', $INTEGER (to_state));

            sfp$emit_statistic (osc$swap_state_stats, descriptive_data (2, * ), ^counters, status);
            IF NOT status.normal THEN
              RETURN;
            IFEND;
          IFEND;
        FOREND;
      FOREND;

    ELSEIF stat_entry.stat = osc$swap_page_count_stats THEN

      counterp [1] := swap_stats_ptr^.swap_file_page_count.swap_count;
      counterp [2] := swap_stats_ptr^.swap_file_page_count.page_count;
      counterp [3] := 0;
      counterp [4] := 0;

      sfp$emit_statistic (osc$swap_page_count_stats, '', ^counterp, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    IFEND;

  PROCEND emit_swap_statistics;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_system_as_data' ??
?? NEWTITLE := 'OS9010' , EJECT ??

  PROCEDURE emit_system_as_data
    (VAR aging_stats_ptr: ^ost$aging_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 18] of integer;

    IF aging_stats_ptr = NIL THEN
      ALLOCATE aging_stats_ptr IN osv$task_private_heap^;
      osp$get_aging_stats (FALSE, aging_stats_ptr^, status);
      IF NOT status.normal THEN
        FREE aging_stats_ptr IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    counters [1] := aging_stats_ptr^.aging_stats.force_aggressive_aging;
    counters [2] := aging_stats_ptr^.aging_stats.aggressive_age_shared_queue;
    counters [3] := aging_stats_ptr^.aging_stats.aggressive_age_job_queues;
    counters [4] := aging_stats_ptr^.aging_stats.aggressive_aging_failed;
    counters [5] := aging_stats_ptr^.aging_stats.age_cp_bound_job;
    counters [6] := aging_stats_ptr^.aging_stats.remove_unmodified_page_from_ws;
    counters [7] := aging_stats_ptr^.aging_stats.remove_modified_page_from_ws;
    counters [8] := aging_stats_ptr^.aging_stats.page_written_to_disk;
    counters [9] := aging_stats_ptr^.aging_stats.multiple_pages_written_to_disk;
    counters [10] := aging_stats_ptr^.aging_stats.calls_to_age_jws;
    counters [11] := aging_stats_ptr^.aging_stats.age_exceeds_aif;
    counters [12] := aging_stats_ptr^.aging_stats.age_exceeds_aic;
    counters [13] := aging_stats_ptr^.aging_stats.age_unused_page_in_shared_queue;
    counters [14] := aging_stats_ptr^.aging_stats.write_aged_out_page;
    counters [15] := aging_stats_ptr^.aging_stats.write_forced_out_page;
    counters [16] := aging_stats_ptr^.aging_stats.write_pt_full_page;
    counters [17] := aging_stats_ptr^.aging_stats.write_avail_mod_page;
    counters [18] := aging_stats_ptr^.aging_stats.write_page_failed;

    sfp$emit_statistic (osc$aging_stats, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_system_as_data;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_system_mr_data' ??
?? NEWTITLE := 'OS9011' , EJECT ??

  PROCEDURE emit_system_mr_data
    (    stat_entry: ost$stat_entry;
     VAR mtr_reqs_ptr: ^ost$mtr_stats;
     VAR status: ost$status);

    VAR
      i: integer,
      loop_start: integer,
      loop_end: integer,
      counters: array [1 .. 6] of integer,
      descriptive_data: string (10),
      length: integer;

    IF mtr_reqs_ptr = NIL THEN
      ALLOCATE mtr_reqs_ptr IN osv$task_private_heap^;
      osp$get_mtr_stats (FALSE, mtr_reqs_ptr^, status);
      IF NOT status.normal THEN
        FREE mtr_reqs_ptr IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    IF stat_entry.first_index <> osc$all_stats THEN
      loop_start := stat_entry.first_index;
      loop_end := stat_entry.second_index;
    ELSE
      loop_start := LOWERBOUND (mtr_reqs_ptr^.mtr_reqs);
      loop_end := UPPERBOUND (mtr_reqs_ptr^.mtr_reqs);
    IFEND;

    FOR i := loop_start TO loop_end DO
      IF (mtr_reqs_ptr^.mtr_reqs [i].count > 0) OR (stat_entry.first_index <> osc$all_stats) THEN
        counters [1] := mtr_reqs_ptr^.mtr_reqs [i].count;
        counters [2] := mtr_reqs_ptr^.mtr_reqs [i].total_cpu_time;
        counters [3] := mtr_reqs_ptr^.mtr_reqs [i].max_time;
        counters [4] := 0;
        counters [5] := 0;
        counters [6] := 0;

        descriptive_data := '';
        STRINGREP (descriptive_data, length, mtr_reqs_ptr^.mtr_reqs [i].req_code);

        sfp$emit_statistic (osc$mtr_req_stats, descriptive_data (2, * ), ^counters, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;
    FOREND;

  PROCEND emit_system_mr_data;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_job_count_stats_hide' ??
?? NEWTITLE := 'OS9013', EJECT ??

  PROCEDURE emit_job_count_stats_hide
    (VAR jm_mm_stats_p: ^ost$jm_mm_stats;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 14] of integer;

    status.normal := TRUE;

    IF jm_mm_stats_p = NIL THEN
      ALLOCATE jm_mm_stats_p IN osv$task_private_heap^;
      osp$get_jm_mm_stats (FALSE, jm_mm_stats_p^, status);
      IF NOT status.normal THEN
        FREE jm_mm_stats_p IN osv$task_private_heap^;
        RETURN;
      IFEND;
    IFEND;

    counters [1] := jm_mm_stats_p^.jm_mm_stats.total_swapped_jobs;
    counters [2] := jm_mm_stats_p^.jm_mm_stats.total_ready_tasks;
    counters [3] := jm_mm_stats_p^.jm_mm_stats.total_ready_but_swapped_tasks;
    counters [4] := jm_mm_stats_p^.jm_mm_stats.total_active_jobs;
    counters [5] := jm_mm_stats_p^.jm_mm_stats.total_system_class;
    counters [6] := jm_mm_stats_p^.jm_mm_stats.total_interactive_jobs;
    counters [7] := jm_mm_stats_p^.jm_mm_stats.total_non_interactive_jobs;

    sfp$emit_statistic (osc$job_count_stats_hide, '', ^counters, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND emit_job_count_stats_hide;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'emit_namve_statistics', EJECT ??

{ PURPOSE:
{   The purpose of this request is to get the data for the intranet statistic
{   counters, the namve statistic counters, osi device specific statistic counters
{   and the osi namve statistic counters and then emit the statistics to the
{   binary statistics log.

  PROCEDURE emit_namve_statistics
    (    stat_entry: ost$stat_entry;
     VAR status: ost$status);

    VAR
      counters: array [1 .. 61] of integer,
      descriptive_data: string (10),
      i: nlt$device_count,
      intranet_counters: array [1 .. 10] of integer,
      length: integer,
      networks_count: nlt$device_count,
      osi_counters: array [1 .. 25] of integer,
      osi_device_specific_counter: array [1 .. 25] of integer;

    status.normal := TRUE;
    IF stat_entry.stat = nac$intranet_stats THEN

{ Emit the intranet layer statistic for each directly connected network solution.

      networks_count := (UPPERBOUND (nav$global_statistics.intranet^) -
            LOWERBOUND (nav$global_statistics.intranet^)) + 1;

      IF intranet_statistic_p = NIL THEN
        IF networks_count > 0 THEN
          ALLOCATE intranet_statistic_p IN osv$task_private_heap^;
          ALLOCATE intranet_statistic_p^.stats: [1 .. networks_count] IN osv$task_private_heap^;
        ELSE
          RETURN;
        IFEND;
      IFEND;

      nap$get_intranet_statistics (FALSE, intranet_statistic_p^);
      FOR i := 1 TO networks_count DO
        intranet_counters [1] := intranet_statistic_p^.stats^ [i].multicasts_received;
        intranet_counters [2] := intranet_statistic_p^.stats^ [i].multicasts_sent;
        intranet_counters [3] := intranet_statistic_p^.stats^ [i].receive.pdu_average;
        intranet_counters [4] := intranet_statistic_p^.stats^ [i].receive.pdu_total;
        intranet_counters [5] := intranet_statistic_p^.stats^ [i].receive_pdus_discarded;
        intranet_counters [6] := intranet_statistic_p^.stats^ [i].send.pdu_average_size;
        intranet_counters [7] := intranet_statistic_p^.stats^ [i].send.pdu_total;
        intranet_counters [8] := intranet_statistic_p^.stats^ [i].send_pdus_discarded;
        intranet_counters [9] := intranet_statistic_p^.stats^ [i].current_send_pdus_queued;
        intranet_counters [10] := intranet_statistic_p^.stats^ [i].send.pdu_fragment_average;

        STRINGREP (descriptive_data, length, intranet_statistic_p^.stats^ [i].network_id: #(16));
        sfp$emit_statistic (nac$intranet_stats, descriptive_data (1, length), ^intranet_counters, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      FOREND;
    IFEND;

    IF stat_entry.stat = nac$namve_stats THEN

{ Emit the NAM/VE statistic.

      IF namve_statistic_p = NIL THEN
        ALLOCATE namve_statistic_p IN osv$task_private_heap^;
      IFEND;

      nap$get_namve_statistics (FALSE, namve_statistic_p^);
      counters [1] := namve_statistic_p^.stats.internet.broadcasts_sent;
      counters [2] := namve_statistic_p^.stats.internet.pdus_received;
      counters [3] := namve_statistic_p^.stats.internet.pdus_sent;
      counters [4] := namve_statistic_p^.stats.internet.pdus_relayed;
      counters [5] := namve_statistic_p^.stats.internet.pdus_routed_locally;

      counters [6] := namve_statistic_p^.stats.transport.initiated_connections;
      counters [7] := namve_statistic_p^.stats.transport.active_connections;
      counters [8] := namve_statistic_p^.stats.transport.reference_number_wait;
      counters [9] := namve_statistic_p^.stats.transport.connections_terminated;
      counters [10] := namve_statistic_p^.stats.transport.data_packets_received;
      counters [11] := namve_statistic_p^.stats.transport.data_packets_sent;
      counters [12] := namve_statistic_p^.stats.transport.discarded_data_packets;
      counters [13] := namve_statistic_p^.stats.transport.duplicate_data_packets;
      counters [14] := namve_statistic_p^.stats.transport.xdata_packets_received;
      counters [15] := namve_statistic_p^.stats.transport.xdata_packets_sent;
      counters [16] := namve_statistic_p^.stats.transport.discarded_xdata_packets;
      counters [17] := namve_statistic_p^.stats.transport.duplicate_xdata_packets;
      counters [18] := namve_statistic_p^.stats.transport.acknowledgment_requests_recved;
      counters [19] := namve_statistic_p^.stats.transport.acknowledgment_requests_sent;
      counters [20] := namve_statistic_p^.stats.transport.acknowledgments_discarded;
      counters [21] := namve_statistic_p^.stats.transport.probe_packets_received;
      counters [22] := namve_statistic_p^.stats.transport.probe_packets_sent;
      counters [23] := namve_statistic_p^.stats.transport.probe_packets_discarded;
      counters [24] := namve_statistic_p^.stats.transport.retransmissions;
      counters [25] := namve_statistic_p^.stats.transport.error_packets_received;
      counters [26] := namve_statistic_p^.stats.transport.error_packets_sent;

      counters [27] := namve_statistic_p^.stats.session.synchronize_requests_received;
      counters [28] := namve_statistic_p^.stats.session.synchronize_requests_sent;
      counters [29] := namve_statistic_p^.stats.session.interrupt_requests_received;
      counters [30] := namve_statistic_p^.stats.session.interrupt_requests_sent;

      counters [31] := namve_statistic_p^.stats.routing.duplicate_received_ridus;
      counters [32] := namve_statistic_p^.stats.routing.ridus_received;
      counters [33] := namve_statistic_p^.stats.routing.ridus_sent;
      counters [34] := namve_statistic_p^.stats.routing.ridus_aged_out;
      counters [35] := namve_statistic_p^.stats.routing.table_recomputed_direct_network;
      counters [36] := namve_statistic_p^.stats.routing.table_recomputed_remote_network;
      counters [37] := namve_statistic_p^.stats.routing.table_partial_updates;

      counters [38] := namve_statistic_p^.stats.directory.current_registered_titles;
      counters [39] := namve_statistic_p^.stats.directory.current_cache_entries;
      counters [40] := namve_statistic_p^.stats.directory.directory_searches_active;
      counters [41] := namve_statistic_p^.stats.directory.directory_searches_initiated;
      counters [42] := namve_statistic_p^.stats.directory.translations_delivered;
      counters [43] := namve_statistic_p^.stats.directory.translations_found_in_local_dir;
      counters [44] := namve_statistic_p^.stats.directory.translations_found_in_cache;
      counters [45] := namve_statistic_p^.stats.directory.broadcast_translations_received;
      counters [46] := namve_statistic_p^.stats.directory.translations_broadcast;
      counters [47] := namve_statistic_p^.stats.directory.translations_received;
      counters [48] := namve_statistic_p^.stats.directory.translations_sent;
      counters [49] := namve_statistic_p^.stats.directory.translation_requests_broadcast;
      counters [50] := namve_statistic_p^.stats.directory.translation_requests_received;

      counters [51] := namve_statistic_p^.stats.file_access.active_connections;
      counters [52] := namve_statistic_p^.stats.file_access.file_access_requests;

      counters [53] := namve_statistic_p^.stats.buffer_manager.descriptor_pool_empty_count;
      counters [54] := namve_statistic_p^.stats.buffer_manager.containers_allocated [1]; {small containers}
      counters [55] := namve_statistic_p^.stats.buffer_manager.containers_allocated [2]; {large containers}
      counters [56] := namve_statistic_p^.stats.buffer_manager.containers_freed [1]; {small containers}
      counters [57] := namve_statistic_p^.stats.buffer_manager.containers_freed [2]; {large containers}

      counters [58] := namve_statistic_p^.stats.pp_buffer_pool.empty_pools_count [1] [1]; {small containers}
      counters [59] := namve_statistic_p^.stats.pp_buffer_pool.empty_pools_count [1] [2]; {large containers}
      counters [60] := namve_statistic_p^.stats.pp_buffer_pool.pools_replenished [1]; {small containers}
      counters [61] := namve_statistic_p^.stats.pp_buffer_pool.pools_replenished [2]; {large containers}

      sfp$emit_statistic (nac$namve_stats, '', ^counters, status);
    IFEND;

    IF stat_entry.stat = nac$osi_device_specific_stats THEN

{ Emit the osi_device_specific layer statistic for each directly connected network solution.

      networks_count := (UPPERBOUND (nav$global_osi_statistics.channel_connection_device^) -
            LOWERBOUND (nav$global_osi_statistics.channel_connection_device^)) + 1;

      IF osi_device_specific_statistic_p = NIL THEN
        IF networks_count > 0 THEN
          ALLOCATE osi_device_specific_statistic_p IN osv$task_private_heap^;
          ALLOCATE osi_device_specific_statistic_p^.statistics: [1 .. networks_count] IN
                osv$task_private_heap^;
        ELSE
          RETURN;
        IFEND;
      IFEND;

      nap$get_osi_device_spec_stats (FALSE, osi_device_specific_statistic_p^);
      FOR i := 1 TO networks_count DO
        osi_device_specific_counter [1] := osi_device_specific_statistic_p^.statistics^ [i].
              credit_pdus_received;
        osi_device_specific_counter [2] := osi_device_specific_statistic_p^.statistics^ [i].credit_pdus_sent;
        osi_device_specific_counter [3] := osi_device_specific_statistic_p^.statistics^ [i].
              current_normal_connections;
        osi_device_specific_counter [4] := osi_device_specific_statistic_p^.statistics^ [i].
              current_priority_connections;
        osi_device_specific_counter [5] := osi_device_specific_statistic_p^.statistics^ [i].device_resets;
        osi_device_specific_counter [6] := osi_device_specific_statistic_p^.statistics^ [i].
              duplicate_connect_indications;
        osi_device_specific_counter [7] := osi_device_specific_statistic_p^.statistics^ [i].
              normal_send_pdus_queued;
        osi_device_specific_counter [8] := osi_device_specific_statistic_p^.statistics^ [i].
              pdus_processed_out_of_order;
        osi_device_specific_counter [9] := osi_device_specific_statistic_p^.statistics^ [i].priority_receive.
              pdu_average;
        osi_device_specific_counter [10] := osi_device_specific_statistic_p^.statistics^ [i].priority_receive.
              pdu_total;
        osi_device_specific_counter [11] := osi_device_specific_statistic_p^.statistics^ [i].
              priority_receive_expedited_pdus;
        osi_device_specific_counter [12] := osi_device_specific_statistic_p^.statistics^ [i].
              priority_receive_pdus_discarded;
        osi_device_specific_counter [13] := osi_device_specific_statistic_p^.statistics^ [i].priority_send.
              pdu_average;
        osi_device_specific_counter [14] := osi_device_specific_statistic_p^.statistics^ [i].priority_send.
              pdu_total;
        osi_device_specific_counter [15] := osi_device_specific_statistic_p^.statistics^ [i].
              priority_send_expedited_pdus;
        osi_device_specific_counter [16] := osi_device_specific_statistic_p^.statistics^ [i].
              priority_send_pdus_discarded;
        osi_device_specific_counter [17] := osi_device_specific_statistic_p^.statistics^ [i].
              priority_send_pdus_queued;
        osi_device_specific_counter [18] := osi_device_specific_statistic_p^.statistics^ [i].receive.
              pdu_average;
        osi_device_specific_counter [19] := osi_device_specific_statistic_p^.statistics^ [i].receive.
              pdu_total;
        osi_device_specific_counter [20] := osi_device_specific_statistic_p^.statistics^ [i].
              receive_pdus_discarded;
        osi_device_specific_counter [21] := osi_device_specific_statistic_p^.statistics^ [i].
              received_expedited_pdus;
        osi_device_specific_counter [22] := osi_device_specific_statistic_p^.statistics^ [i].send.pdu_average;
        osi_device_specific_counter [23] := osi_device_specific_statistic_p^.statistics^ [i].send.pdu_total;
        osi_device_specific_counter [24] := osi_device_specific_statistic_p^.statistics^ [i].
              send_expedited_pdus;
        osi_device_specific_counter [25] := osi_device_specific_statistic_p^.statistics^ [i].
              send_pdus_discarded;

        STRINGREP (descriptive_data, length, osi_device_specific_statistic_p^.statistics^ [i].
              network_id: #(16));
        sfp$emit_statistic (nac$osi_device_specific_stats, descriptive_data (1, length),
              ^osi_device_specific_counter, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      FOREND;
    IFEND;

    IF stat_entry.stat = nac$osi_stats THEN

{ Emit the NAM/VE OSI layer statistics.

      IF osi_statistic_p = NIL THEN
        ALLOCATE osi_statistic_p IN osv$task_private_heap^;
      IFEND;

      nap$get_osi_statistics (FALSE, osi_statistic_p^);
      osi_counters [1] := osi_statistic_p^.statistics.channel_connection.broadcast_connect_requests;
      osi_counters [2] := osi_statistic_p^.statistics.channel_connection.normal_connections;
      osi_counters [3] := osi_statistic_p^.statistics.channel_connection.priority_connections;

      osi_counters [4] := osi_statistic_p^.statistics.link_access_agent.current_saps_open;
      osi_counters [5] := osi_statistic_p^.statistics.link_access_agent.pdus_received;
      osi_counters [6] := osi_statistic_p^.statistics.link_access_agent.pdus_sent;
      osi_counters [7] := osi_statistic_p^.statistics.link_access_agent.total_bytes_received;
      osi_counters [8] := osi_statistic_p^.statistics.link_access_agent.total_bytes_sent;

      osi_counters [9] := osi_statistic_p^.statistics.network_access_agent.broadcasts_sent;
      osi_counters [10] := osi_statistic_p^.statistics.network_access_agent.pdus_received;
      osi_counters [11] := osi_statistic_p^.statistics.network_access_agent.pdus_sent;
      osi_counters [12] := osi_statistic_p^.statistics.network_access_agent.total_bytes_received;
      osi_counters [13] := osi_statistic_p^.statistics.network_access_agent.total_bytes_sent;

      osi_counters [14] := osi_statistic_p^.statistics.system_management_entity.cdna_address_route_unknown;
      osi_counters [15] := osi_statistic_p^.statistics.system_management_entity.
            cdna_address_select_device_reqs;
      osi_counters [16] := osi_statistic_p^.statistics.system_management_entity.
            noncdna_addr_select_device_reqs;
      osi_counters [17] := osi_statistic_p^.statistics.system_management_entity.noncdna_address_route_unknown;
      osi_counters [18] := osi_statistic_p^.statistics.system_management_entity.device_routing_queries;
      osi_counters [19] := osi_statistic_p^.statistics.system_management_entity.subnet_attribute_updates_rcvd;

      osi_counters [20] := osi_statistic_p^.statistics.transport_access_agent.data_pdus_received;
      osi_counters [21] := osi_statistic_p^.statistics.transport_access_agent.data_pdus_sent;
      osi_counters [22] := osi_statistic_p^.statistics.transport_access_agent.expedited_pdus_received;
      osi_counters [23] := osi_statistic_p^.statistics.transport_access_agent.expedited_pdus_sent;
      osi_counters [24] := osi_statistic_p^.statistics.transport_access_agent.total_bytes_received;
      osi_counters [25] := osi_statistic_p^.statistics.transport_access_agent.total_bytes_sent;

      sfp$emit_statistic (nac$osi_stats, '', ^osi_counters, status);
    IFEND;

  PROCEND emit_namve_statistics;
?? OLDTITLE ??
?? OLDTITLE ??
?? NEWTITLE := 'Main procedure' ??
?? NEWTITLE := '[XDCL, #GATE] osp$emit_os_statistics' , EJECT ??

{ PURPOSE:
{   This procedure arranges for the system task to call again at the
{   appropriate time, and emits the correct statistic.

  PROCEDURE [XDCL, #GATE] osp$emit_os_statistics;

    VAR
      counter: array [1 .. 1] of integer,
      current_time: integer,
      emission_sets_copy: array [ost$emission_set_names] of ost$emission_set,
      emission_set: ost$emission_set_names,
      new_emit_time: integer,
      status: ost$status,
      stat_entry: 1 .. osc$max_stats_in_set;

    VAR
      aging_stats_p: ^ost$aging_stats,
      cpu_stats_p: ^ost$cpu_stats,
      jm_mm_stats_p: ^ost$jm_mm_stats,
      job_stats_p: ^ost$job_stats,
      mtr_reqs_p: ^ost$mtr_stats,
      page_fault_stats_p: ^ost$page_fault_stats,
      paging_stats_p: ^ost$paging_stats,
      pio_disk_space_stats_p: ^ost$disk_space_stats,
      pio_pp_stats_p: ^ost$disk_pp_stats,
      pio_unit_stats_p: ^ost$disk_unit_stats,
      server_page_fault_stats_p: ^ost$page_fault_stats,
      swap_stats_p: ^ost$swap_stats,
      system_job_stats_p: ^ost$job_stats,
      system_task_stats_p: ^ost$task_stats;

    status.normal := TRUE;

    aging_stats_p := NIL;
    cpu_stats_p := NIL;
    jm_mm_stats_p := NIL;
    job_stats_p:= NIL;
    mtr_reqs_p := NIL;
    page_fault_stats_p := NIL;
    paging_stats_p := NIL;
    pio_disk_space_stats_p := NIL;
    pio_pp_stats_p := NIL;
    pio_unit_stats_p := NIL;
    server_page_fault_stats_p := NIL;
    swap_stats_p := NIL;
    system_job_stats_p := NIL;
    system_task_stats_p := NIL;

    current_time := #FREE_RUNNING_CLOCK (0);
    counter [1] := current_time;

    sfp$emit_statistic (osc$begin_os_emission_set, '', ^counter, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    osp$emit_os_statistics_r1 (current_time, emission_sets_copy);

    FOR emission_set := LOWERVALUE (ost$emission_set_names) TO UPPERVALUE (ost$emission_set_names) DO
      IF (emission_sets_copy [emission_set].enabled) AND
            (emission_sets_copy [emission_set].next_emit_time <= current_time) THEN

        FOR stat_entry := 1 TO emission_sets_copy [emission_set].stat_count DO

          CASE emission_sets_copy [emission_set].stat_list [stat_entry].stat OF

          = nac$namve_stats .. nac$osi_device_specific_stats =
            IF nav$statistics_enabled AND nav$namve_active THEN
              emit_namve_statistics (emission_sets_copy [emission_set].stat_list [stat_entry], status);
            IFEND;

          = { OS0 } osc$job_and_memory_stats =
            emit_job_and_memory_stats (jm_mm_stats_p, status);

          = { OS1 } osc$paging_and_mtr_stats =
            emit_paging_and_mtr_stats (page_fault_stats_p, server_page_fault_stats_p, aging_stats_p,
                  mtr_reqs_p, paging_stats_p, status);

          = { OS2 - OS5 } osc$io_pp_usage .. osc$io_disk_space =
            emit_pio_statistics (emission_sets_copy [emission_set].stat_list [stat_entry],
                  pio_pp_stats_p, pio_unit_stats_p, pio_disk_space_stats_p, status);

          = { OS6 } osc$cpu_stats =
            emit_cpu_statistics (cpu_stats_p, mtr_reqs_p, status);

          = { OS7 } osc$service_class_stats =
            emit_service_class_stats (status);

          = { OS8 } osc$job_class_stats =
            emit_job_class_stats (status);

          = { OS9 } osc$system_job_stats =
            emit_system_job_stats (system_job_stats_p, status);

          = { OS10 } osc$system_task_stats =
            emit_system_task_stats (system_task_stats_p, status);

          = { OS11 } osc$memory_utilization_stats =
            emit_memory_stats (jm_mm_stats_p, status);

          = { OS12 } osc$job_count_stats =
            emit_job_count_stats (jm_mm_stats_p, status);

          = { OS13 } osc$page_streaming_stats =
            emit_page_streaming_stats (paging_stats_p, status);

          = { OS14 } osc$monitor_request_stats =
            emit_system_mr_stats (mtr_reqs_p, status);

          = { OS15 } osc$cpu_dispatching_stats =
            emit_cpu_dispatching_stats (cpu_stats_p,status);

          = { OS16 } osc$page_fault_rejected_stats =
            emit_page_fault_rejected_stats (page_fault_stats_p, server_page_fault_stats_p, status);

          = { OS9005 } osc$system_job_stats_hide  =
            emit_system_job_stats_hide (status);

          = { OS9007, OS9008 } osc$swap_state_stats, osc$swap_page_count_stats =
            emit_swap_statistics (emission_sets_copy [emission_set].stat_list [stat_entry],
                swap_stats_p, status);

          = { OS9010 } osc$aging_stats =
            emit_system_as_data (aging_stats_p, status);

          = { OS9011 } osc$mtr_req_stats =
            emit_system_mr_data (emission_sets_copy [emission_set].stat_list [stat_entry],
                mtr_reqs_p, status);

          = { OS9013 } osc$job_count_stats_hide =
            emit_job_count_stats_hide (jm_mm_stats_p, status);

          ELSE { No statistic is emitted }

          CASEND;

          IF NOT status.normal THEN
            aborted_condition := status.condition;
            pmp$log ('--An error ocurred while emitting periodic statistics--', status);
            status.normal := TRUE;
          IFEND;

        FOREND;
      IFEND;
    FOREND;

    sfp$emit_statistic (osc$end_os_emission_set, '', ^counter, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Free buffers allocated by local procedures.

    IF aging_stats_p <> NIL THEN
      FREE aging_stats_p IN osv$task_private_heap^;
    IFEND;
    IF cpu_stats_p <> NIL THEN
      FREE cpu_stats_p IN osv$task_private_heap^;
    IFEND;
    IF jm_mm_stats_p <> NIL THEN
      FREE jm_mm_stats_p IN osv$task_private_heap^;
    IFEND;
    IF job_stats_p <> NIL THEN
      FREE job_stats_p IN osv$task_private_heap^;
    IFEND;
    IF mtr_reqs_p <> NIL THEN
      FREE mtr_reqs_p IN osv$task_private_heap^;
    IFEND;
    IF page_fault_stats_p <> NIL THEN
      FREE page_fault_stats_p IN osv$task_private_heap^;
    IFEND;
    IF paging_stats_p <> NIL THEN
      FREE paging_stats_p IN osv$task_private_heap^;
    IFEND;
    IF pio_disk_space_stats_p <> NIL THEN
      FREE pio_disk_space_stats_p IN osv$task_private_heap^;
    IFEND;
    IF pio_pp_stats_p <> NIL THEN
      FREE pio_pp_stats_p IN osv$task_private_heap^;
    IFEND;
    IF pio_unit_stats_p <> NIL THEN
      FREE pio_unit_stats_p IN osv$task_private_heap^;
    IFEND;
    IF server_page_fault_stats_p <> NIL THEN
      FREE server_page_fault_stats_p IN osv$task_private_heap^;
    IFEND;
    IF swap_stats_p <> NIL THEN
      FREE swap_stats_p in osv$task_private_heap^;
    IFEND;
    IF system_job_stats_p <> NIL THEN
      FREE system_job_stats_p in osv$task_private_heap^;
    IFEND;
    IF system_task_stats_p <> NIL THEN
      FREE system_task_stats_p in osv$task_private_heap^;
    IFEND;
    IF intranet_statistic_p <> NIL THEN
      IF intranet_statistic_p^.stats <> NIL THEN
        FREE intranet_statistic_p^.stats IN osv$task_private_heap^;
      IFEND;
      FREE intranet_statistic_p IN osv$task_private_heap^;
    IFEND;
    IF namve_statistic_p <> NIL THEN
      FREE namve_statistic_p IN osv$task_private_heap^;
    IFEND;
    IF osi_device_specific_statistic_p <> NIL THEN
      IF osi_device_specific_statistic_p^.statistics <> NIL THEN
        FREE osi_device_specific_statistic_p^.statistics IN osv$task_private_heap^;
      IFEND;
      FREE osi_device_specific_statistic_p IN osv$task_private_heap^;
    IFEND;
    IF osi_statistic_p <> NIL THEN
      FREE osi_statistic_p IN osv$task_private_heap^;
    IFEND;
  PROCEND osp$emit_os_statistics;
?? OLDTITLE ??
?? OLDTITLE ??
?? OLDTITLE ??
MODEND osm$emit_os_statistics;
