MODULE ofm$swap_statistics_display;
?? RIGHT := 110 ??

{ PURPOSE:
{   Supports the following Swap File Statistics VED displays
{     SWAP_STATE_STATISTICS, SSS
{     SWAP_STATE_STATISTICS_TOTAL, SSST
{     SWAP_TRACE_STATISTICS, STS
{     SWAP_TRACE_STATISTICS_TOTAL, STST
{
{ DESIGN:
{   Displays data out of jsv$swap_trace

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc oss$job_paged_literal
*copyc oss$task_shared
*copyc clt$value
*copyc clt$display_control
*copyc jmt$system_supplied_name
*copyc ost$status
*copyc ost$string
?? POP ??
*copyc clp$close_display
*copyc clp$new_display_line
*copyc clp$put_display
*copyc dpp$clear_window
*copyc dpp$put_next_line
*copyc ofp$build_system_line
*copyc ofp$open_display
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc pmp$binary_to_ascii_fit
*copyc jsv$swap_status_id_array
*copyc osv$task_shared_heap
*copyc syv$nos_system_time
?? EJECT ??
*copyc jsv$swap_file_page_count
*copyc jsv$swap_state_statistics

?? FMT (FORMAT := OFF) ??

  CONST
{  Define trace indexes for swap trace buffer.  JSC$TI_UNUSED_XX identifies free indexes.
    jsc$ti_min_index = 0,
    jsc$ti_no_memory_for_swap_in = 1,
    jsc$ti_new_job_fixed_asid = 2,
    jsc$ti_reuse_job_fixed_asid = 3,
    jsc$ti_reuse_job_fixed_asid_as = 4,    { Reassign old ASID to job fixed.}
    jsc$ti_no_pages_for_sfd_on_si = 5,
    jsc$ti_sfd_freed = 6,
    jsc$ti_free_memory_si_aborted = 7,
    jsc$ti_free_memory = 8,
    jsc$ti_no_mem_from_claim_pages = 9,
    jsc$ti_pager_io_error = 10,
    jsc$ti_move_am_back_to_am = 11,
    jsc$ti_move_am_back_to_am_pc = 12,     { Page count of pages moved back to available modified.}
    jsc$ti_flush_am_pc = 13,               { Page count of pages in am that were flushed.}
    jsc$ti_flush_am_relink = 14,           { Move am back to jws--write to disk reject.}
    jsc$ti_flush_am_ready = 15,            { Task ready after flush.}
    jsc$ti_swapping_queue_and_exec = 16,   { Swap status of executing and swap direction of in.}
    jsc$ti_allocate_swap_file = 17,        { Call DM to allocate swap file in monitor mode.}
    jsc$ti_allocate_swap_file_jm = 18,     { Allocate swap file in job mode.}
    jsc$ti_dm_transient_error = 19,        { Device management transient error.}
    jsc$ti_change_asid_again = 20,
    jsc$ti_change_asid = 21,
    jsc$ti_change_asid_sfd = 22,           { Update changed ASID's in swap file descriptor.}

{  Trace indexes for events during reset to memory manager tables.

    jsc$ti_rmmt_no_change = 24,            { No change in ASID.}
    jsc$ti_rmmt_pf = 25,                   { ASID change of page belonging to a permanent file.}
    jsc$ti_rmmt_pf_rec_ptm = 26,           { Assign new ASID on job recovery and modified.}
    jsc$ti_rmmt_pf_rec_ptu = 27,           { Job recovery, relink unmodified page into free queue.}
    jsc$ti_rmmt_pf_assign_asid = 28,       { Not job recovery, assign new ASID.}
    jsc$ti_rmmt_pf_reuse_asid = 29,        { Not job recovery, reuse ASID.}
    jsc$ti_rmmt_lf_assign_asid = 30,       { Assign ASID for page assigned to local file.}
    jsc$ti_rmmt_lf_reuse_asid = 31,        { Reuse ASID for page assigned to local file.}
    jsc$ti_rmmt_pt_done = 32,
    jsc$ti_rmmt_pt_full = 33,
    jsc$ti_rmmt_pt_full_failed = 34,
    jsc$ti_rmmt_pt_full_succ = 35,         { Succeeded in recovering from page table full.}
    jsc$ti_rmmt_pte_exists_pf = 36,        { Permanent file page is now in shared queue.}
    jsc$ti_rmmt_pte_exists_am = 37,        { Local file page is still in Avail modeified queue.}
    jsc$ti_rmmt_pte_exists_a = 38,         { Local file page found in Avail queue.}
    jsc$ti_rmmt_pte_exists_err = 39,       { Local file page found in Swapped error queue.}

{  Trace buffer indexes for reset xcb and sdt tables.

    jsc$ti_rxcb_temp_asids_changed = 40,
    jsc$ti_rxcb_job_asids_changed = 41,
    jsc$ti_rxcb_glob_asids_changed = 42,
    jsc$ti_rxcb_fix_xcb_sdt = 43,
    jsc$ti_rxcb_fix_asids = 44,
    jsc$ti_rxcb_fix_templ_asid = 45,
    jsc$ti_pt_full_reassign_jf = 46,
    jsc$ti_rxcb_fix_jf_asid = 47,
    jsc$ti_rxcb_fix_job_asid = 48,
    jsc$ti_rxcb_zero_job_asid = 49,
    jsc$ti_rxcb_recovery = 53,
    jsc$ti_rxcb_zero_asid = 54,            { Reset tables zeroed out an ASID in a segment table.}

    jsc$ti_lwa = 55,                       { Long wait aging called}
    jsc$ti_lwa_cp_age = 56,                { called cp aging}
    jsc$ti_lwa_stale_pages_rem = 57,       { total number of pages removed}
    jsc$ti_lwa_stale_mod_pages_rem = 58,   { number modified pages removed}
    jsc$ti_lwa_ready_task = 59,            { long wait aging caused task to go ready.}

    jsc$ti_swapin_io_error = 60,
    jsc$ti_swapout_io_error = 61,
    jsc$ti_sif_idle_tasks_init = 63,       { Swap in from idle tasks initiated.}
    jsc$ti_sif_wait_state = 64,            { Swap in from a wait state.}
    jsc$ti_sif_swapout_io_init = 65,       { Swap in from swap out io initiated or completed.}
    jsc$ti_swapout_int_by_swapin = 67,     { Swap in requested on job being swapped out.}
    jsc$ti_swapin_int_by_swapout = 68,     { Swap out requested on job being swapped in.}
    jsc$ti_no_ajl_ord_for_swap_in = 69,    { Swap in aborted, could not assign AJL ordinal.}
    jsc$ti_swapout_from_job_mode = 76,     { Swapout request from job mode}
    jsc$ti_swapout_from_mtr_mode = 77,     { Swapout from monitor mode.}
    jsc$ti_swapin_from_job_mode = 78,      { Swapin from job mode.}
    jsc$ti_swapin_from_mtr_mode = 79,      { Swapin from monitor mode.}
    jsc$ti_swapin_mtr_direct = 80,         { Swapin from monitor mode - S0 to R.}
    jsc$ti_swapin_req_status_bad = 81,     { Swapin from job mode--advance_swap got bad status.}
    jsc$ti_cd_idle_task_complete = 82,     { Change direction to in detected in idld task complete.}
    jsc$ti_sif_idled_tasks_comp = 83,      { Swap in from idle tasks complete.}
    jsc$ti_cd_idle_task_complete_2 = 86,   { Change direction to IN in idle task complete--2nd check.}
    jsc$ti_reserve_memory_failed = 87,     { Memory no longer available for reserve request on swapin.}
    jsc$ti_cd_to_in_at_s2 = 88,            { Changed direction to in at swapped_io_complete.}
    jsc$ti_cd_to_in_at_s = 89,             { Changed direction to in at swapout_complete.}
    jsc$ti_init_swapin_io_error = 90,      { IO error discovered upon swapin io complete.}
    jsc$ti_init_swapout_io_error = 91,     { IO error discovered upon swapout io complete.}
    jsc$ti_swapout_disk_down = 93,         { Disk down discovered upon swapout io complete.}
    jsc$ti_swapin_disk_down = 94,          { Disk down discovered upn swapin io compelete.}
    jsc$ti_zero_out_pages_for_sfd_1 = 95,  { Abort swapout at wait alloc sfd--swapin req--0 out pages needed.}
    jsc$ti_zero_out_pages_for_sfd_2 = 96,  { Adv swapout from wait alloc sfd--polling--0 out pages needed.}
    jsc$ti_no_ajlo_swapin_before_io = 97,  { No ajlo available in swapin_before_io. }
    jsc$ti_dump_shared_q_for_sfd = 98,     { Dump the shared queue to get pages for an SFD.}
    jsc$ti_dump_shared_queue = 99,         { Dump the shared queue to claim enough pages to swap a job in.}
    jsc$ti_free_readied_s2_job = 100,      { Free an S2 job that has been readied in order to use its memory.}
    jsc$ti_no_ajlo_swapin_after_io = 101,  { No ajlo available in swapin_after_io. }
    jsc$ti_advance_from_cannot_init = 103, { Advance swap state from io_cannot_init to io_not_init. }
    jsc$ti_page_q_counts_different = 104,  { Page q counts different at job_io_complete. }
    jsc$ti_mtr_req_adv_from_aj = 105,      { Mtr request to advance from job_allocate_swap_file. }
    jsc$ti_mtr_req_adv_from_sd = 106,      { Mtr request to advance from swapped_io_cannot_init. }
    jsc$ti_recalculate_sje = 107,          { Recalculate the sje after removing a job shared page. }
    jsc$ti_recal_sje_s0 = 108,             { Recalculate the sje -- S0 state. }
    jsc$ti_recal_sje_s2 = 109,             { Recalculate the sje -- S2 state. }

    jsc$ti_riop_relinked = 110,            { Pages relinked into JWS from swapped error queue.}
    jsc$ti_riop_mem_freed = 111,           { IO error page belonging to a job that had freed memory.}
    jsc$ti_riop_m_bit_reset = 112,         { Pages that needed to have M bit set.}
    jsc$ti_riop_init = 113,                { IO error occurred on an initial write.}

    jsc$ti_no_ajlo_mtr_swapin = 114,
    jsc$ti_no_s2_job_found = 115,          { Mmv$reassignable_page_frames.now has gone bad.}
    jsc$ti_now_count_reset = 116,

    jsc$ti_job_aged_before_swap = 117,     { Age before swap tried.
    jsc$ti_age_before_swap_pages = 118,    { Number of pages freed by aging.
    jsc$ti_age_before_swap_okay = 119,     { Aging freed enough pages.  Do not continue swapout.

    jsc$ti_max_index = 150;

?? FMT (FORMAT := ON) ??

  VAR
    jsv$swap_trace: [XREF] array [jsc$ti_min_index .. jsc$ti_max_index] of integer;

  VAR
    v$swap_status_name_array: [READ, oss$job_paged_literal] array [jmt$ijl_swap_status] of string (23) := [
{ } 'Null                   ',
{ } 'Executing              ',
{ } 'Idle Tasks Initiated   ',
{ } 'Job Idle Tasks Complete',
{ } 'Swapped no IO          ',
{ } 'Flush AM Pages         ',
{ } 'Job Allocate Swap File ',
{ } 'Wait Allocate Swap File',
{ } 'Allocate Swap File     ',
{ } 'Wait Job IO Complete   ',
{ } 'Job IO Complete        ',
{ } 'Wait Allocate SFD      ',
{ } 'Allocate SFD           ',
{ } 'Swapped IO Cannot Init ',
{ } 'Initiate Swapout IO    ',
{ } 'Wait Swapout IO Init   ',
{ } 'Swapout IO Initiated   ',
{ } 'Swapout IO Complete    ',
{ } 'Swapped IO Complete    ',
{ } 'Free Swapped Memory    ',
{ } 'Swapout Complete       ',
{ } 'Swapin Requested       ',
{ } 'Swapin Resource Claimed',
{ } 'Wait Swapin IO Init    ',
{ } 'Swapin IO Initiated    ',
{ } 'Swapin IO Complete     '];

?? OLDTITLE ??
?? NEWTITLE := 'P$SWAP_STATE_STATISTICS_DISPLAY', EJECT ??

  PROCEDURE p$swap_state_statistics_display
    (    title_1: string ( * <= 80);
         title_2: string ( * <= 80);
         total_display: boolean;
         wid: dpt$window_id;
         display_name: ost$name;
         file_name: amt$local_file_name;
         initial_call: boolean;
     VAR status: ost$status);

    VAR
      v$previous_display_data_p: [STATIC, oss$task_shared] ^jst$swap_state_statistics := NIL,
      v$previous_swap_file_page_count: [STATIC, oss$task_shared] jst$swap_file_page_count := [0, 0],
      v$system_line_info: [STATIC, oss$task_shared] ^oft$system_line_info := NIL,
      v$previous_time: [STATIC, oss$task_shared] ost$free_running_clock := 0;

    VAR
      display_control: clt$display_control,
      entry: jst$swap_state_statistics_entry,
      from_state: jmt$ijl_swap_status,
      i: integer,
      interval_in_seconds: real,
      len: integer,
      current_swap_file_page_count: jst$swap_file_page_count,
      swap_file_page_count: jst$swap_file_page_count,
      swap_in_out_counts: array [jmt$ijl_swap_status] of record
        in_count: integer,
        out_count: integer,
        total: integer,
      recend,
      s: string (80),
      swap_rate: real,
      time: ost$free_running_clock,
      to_state: jmt$ijl_swap_status;

?? NEWTITLE := 'P$ABORT_HANDLER', EJECT ??

{ PURPOSE:
{   This procedure provides clean-up processing when a task abort occurs.

    PROCEDURE p$abort_handler
      (    condition: pmt$condition;
           condition_information_p: ^pmt$condition_information;
           save_area_p: ^ost$stack_frame_save_area;
       VAR handler_status: ost$status);

      VAR
        ignore_status: ost$status;

      IF wid = 0 THEN
        clp$close_display (display_control, ignore_status);
      IFEND;

    PROCEND p$abort_handler;
?? OLDTITLE ??
?? NEWTITLE := 'P$PUT_LINE', EJECT ??

    PROCEDURE [INLINE] p$put_line
      (    s: string (80));

      IF wid <> 0 THEN
        dpp$put_next_line (wid, s (1, 80), status);
      ELSE
        clp$put_display (display_control, s, clc$trim, status);
      IFEND;

    PROCEND p$put_line;
?? OLDTITLE ??
?? EJECT ??
    status.normal := TRUE;
    IF wid = 0 THEN
      osp$establish_block_exit_hndlr (^p$abort_handler);
    ELSE
      dpp$clear_window (wid, status);
    IFEND;
    IF initial_call THEN
      ofp$open_display (file_name, wid, dpc$wc_sharing, dpc$wk_table, title_1, display_control, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
    IFEND;

{ Establish base values for the general statistics display if they do not already exist.
    IF v$system_line_info = NIL THEN
      ALLOCATE v$system_line_info IN osv$task_shared_heap^;
      v$system_line_info^.initialized := FALSE;
    IFEND;

    IF (total_display = FALSE) AND (v$previous_display_data_p = NIL) THEN
      ALLOCATE v$previous_display_data_p IN osv$task_shared_heap^;
      v$previous_time := #FREE_RUNNING_CLOCK (0) - syv$nos_system_time.corresponding_frc;
      v$previous_swap_file_page_count.page_count := 0;
      v$previous_swap_file_page_count.swap_count := 0;
      FOR from_state := LOWERVALUE (jmt$ijl_swap_status) TO UPPERVALUE (jmt$ijl_swap_status) DO
        FOR to_state := LOWERVALUE (jmt$ijl_swap_status) TO UPPERVALUE (jmt$ijl_swap_status) DO
          v$previous_display_data_p^ [from_state] [to_state].count := 0;
          v$previous_display_data_p^ [from_state] [to_state].maximum_time := 0;
          v$previous_display_data_p^ [from_state] [to_state].total_time := 0;
        FOREND;
      FOREND;
    IFEND;

    time := #FREE_RUNNING_CLOCK (0) - syv$nos_system_time.corresponding_frc;
    IF total_display THEN
      interval_in_seconds := $REAL (time) / 1000000.0;
    ELSE
      interval_in_seconds := $REAL (time - v$previous_time) / 1000000.0;
      v$previous_time := time;
    IFEND;
    ofp$build_system_line (v$system_line_info^, s);
    p$put_line (s);
    s := '';
    p$put_line (s);
    s := title_2;
    p$put_line (s);

    current_swap_file_page_count := jsv$swap_file_page_count;
    IF total_display THEN
      swap_file_page_count := jsv$swap_file_page_count;
    ELSE
      current_swap_file_page_count := jsv$swap_file_page_count;
      swap_file_page_count.swap_count := current_swap_file_page_count.swap_count -
            v$previous_swap_file_page_count.swap_count;
      swap_file_page_count.page_count := current_swap_file_page_count.page_count -
            v$previous_swap_file_page_count.page_count;
      v$previous_swap_file_page_count := current_swap_file_page_count;
    IFEND;

    FOR to_state := LOWERVALUE (jmt$ijl_swap_status) TO UPPERVALUE (jmt$ijl_swap_status) DO
      swap_in_out_counts [to_state].in_count := 0;
      swap_in_out_counts [to_state].out_count := 0;
      swap_in_out_counts [to_state].total := 0;
    FOREND;

    FOR from_state := LOWERVALUE (jmt$ijl_swap_status) TO UPPERVALUE (jmt$ijl_swap_status) DO
      FOR to_state := LOWERVALUE (jmt$ijl_swap_status) TO UPPERVALUE (jmt$ijl_swap_status) DO
        entry := jsv$swap_state_statistics [from_state] [to_state];
        IF NOT total_display THEN
          entry.count := entry.count - v$previous_display_data_p^ [from_state] [to_state].count;
          entry.total_time := entry.total_time - v$previous_display_data_p^ [from_state] [to_state].
                total_time;
          v$previous_display_data_p^ [from_state] [to_state] := entry;
        IFEND;

        swap_in_out_counts [to_state].in_count := swap_in_out_counts [to_state].in_count + entry.count;
        swap_in_out_counts [from_state].out_count := swap_in_out_counts [from_state].out_count + entry.count;
        swap_in_out_counts [to_state].total := swap_in_out_counts [to_state].total +
              jsv$swap_state_statistics [from_state] [to_state].count;
        swap_in_out_counts [from_state].total := swap_in_out_counts [from_state].total +
              jsv$swap_state_statistics [from_state] [to_state].count;

{ States are displayed, even when the current difference is 0. Otherwise, the screen will
{ get bigger and smaller with every call.

        IF jsv$swap_state_statistics [from_state] [to_state].count <> 0 THEN
          s := ' ';
          s (5, 2) := jsv$swap_status_id_array [from_state];
          s (10, 2) := jsv$swap_status_id_array [to_state];
          IF interval_in_seconds <> 0.0 THEN
            swap_rate := $REAL (entry.count) / interval_in_seconds;
          ELSE
            swap_rate := 0.0;
          IFEND;

          pmp$binary_to_ascii_fit (entry.count, 10, 8, 8, s (12, 8));
          IF entry.count = 0 THEN
            pmp$binary_to_ascii_fit (0, 10, 10, 10, s (20, 10));
          ELSE
            pmp$binary_to_ascii_fit (entry.total_time DIV entry.count, 10, 10, 10, s (20, 10));
          IFEND;

          STRINGREP (s (30, 11), len, swap_rate: 11: 1);
          pmp$binary_to_ascii_fit (entry.maximum_time, 10, 11, 11, s (44, 11));
          p$put_line (s);
        IFEND;
      FOREND;
    FOREND;

    s := ' ';
    p$put_line (s);
    s := 'Swap File Page Count  :                  Swap Count:';
    pmp$binary_to_ascii_fit (swap_file_page_count.page_count, 10, 9, 9, s (25, 9));
    pmp$binary_to_ascii_fit (swap_file_page_count.swap_count, 10, 9, 9, s (54, 9));
    p$put_line (s);

    s := 'Average swap file size:           ';
    IF swap_file_page_count.swap_count > 0 THEN
      STRINGREP (s (25, 9), len, $REAL (swap_file_page_count.page_count) /
            $REAL (swap_file_page_count.swap_count): 9: 2);
    ELSE
      s (25, 9) := '     0.00';
    IFEND;
    p$put_line (s);

    s := ' ';
    p$put_line (s);
    s := 'Swap State                      In Count      Out Count     Difference';
    p$put_line (s);

    FOR to_state := LOWERVALUE (jmt$ijl_swap_status) TO UPPERVALUE (jmt$ijl_swap_status) DO
      IF (swap_in_out_counts [to_state].total <> 0) OR (swap_in_out_counts [from_state].total <> 0) THEN
        s := ' ';
        s (1, 2) := jsv$swap_status_id_array [to_state];
        s (4) := '-';
        s (6, 23) := v$swap_status_name_array [to_state];
        pmp$binary_to_ascii_fit (swap_in_out_counts [to_state].in_count, 10, 9, 9, s (31, 10));
        pmp$binary_to_ascii_fit (swap_in_out_counts [to_state].out_count, 10, 9, 9, s (46, 10));
        pmp$binary_to_ascii_fit (swap_in_out_counts [to_state].out_count -
              swap_in_out_counts [to_state].in_count, 10, 9, 9, s (61, 10));
        p$put_line (s);
      IFEND;
    FOREND;

    IF wid = 0 THEN
      clp$close_display (display_control, status);
      osp$disestablish_cond_handler;
    IFEND;

  PROCEND p$swap_state_statistics_display;
?? OLDTITLE ??
?? NEWTITLE := 'P$SWAP_TRACE_STATISTICS_DISPLAY', EJECT ??

  PROCEDURE p$swap_trace_statistics_display
    (    title: string ( * <= 40);
         total_display: boolean;
         wid: dpt$window_id;
         display_name: ost$name;
         file_name: amt$local_file_name;
         initial_call: boolean;
     VAR status: ost$status);

    CONST
      c$first_line = 1,
      c$last_line = c$last_data_line,
      c$data_line_count = 49,

      c$system_line_info = c$first_line,
      c$first_data_line = c$first_line + 1,
      c$last_data_line = c$first_data_line + c$data_line_count - 1;

    TYPE
      t$screen_definition = record
        index: jsc$ti_min_index .. jsc$ti_max_index,
        description: string (25),
      recend;

    CONST
      c$no_index = 0;

?? FMT (FORMAT := OFF) ??

    VAR
      v$screen_definitions_left: [READ, oss$job_paged_literal] array [c$first_data_line .. c$last_data_line]
            of t$screen_definition := [
{ 01 } [c$no_index,                     'Swap Trace Statistics    '],
{ 02 } [c$no_index,                     '    LONG WAIT AGING / LWA'],
{ 03 } [jsc$ti_lwa,                     '  Long Wait Aging called:'],
{ 04 } [jsc$ti_lwa_cp_age,              '         CP aging called:'],
{ 05 } [jsc$ti_lwa_stale_pages_rem,     '     Total Pages removed:'],
{ 06 } [jsc$ti_lwa_stale_mod_pages_rem, '  Modified Pages removed:'],
{ 07 } [jsc$ti_lwa_ready_task,          '   LWA caused task ready:'],
{ 08 } [c$no_index,                     '                         '],
{ 09 } [c$no_index,                     '  FLUSH AM DURING SWAPOUT'],
{ 10 } [jsc$ti_flush_am_pc,             '     Pages in AM flushed:'],
{ 11 } [jsc$ti_flush_am_relink,         'Linked to JWS-Wrt reject:'],
{ 12 } [jsc$ti_flush_am_ready,          '  Task Ready after Flush:'],
{ 13 } [c$no_index,                     '                         '],
{ 14 } [c$no_index,                     '                 SWAP OUT'],
{ 15 } [jsc$ti_swapout_from_job_mode,   ' Jobs Swapout JM R -> OR:'],
{ 16 } [jsc$ti_swapout_from_mtr_mode,   ' Jobs Swapout MM R -> OR:'],
{ 17 } [jsc$ti_swapout_int_by_swapin,   '    Swapin while Swapout:'],
{ 18 } [jsc$ti_allocate_swap_file,      ' Allocate Swapfile in MM:'],
{ 19 } [jsc$ti_allocate_swap_file_jm,   ' Allocate Swapfile in JM:'],
{ 20 } [jsc$ti_free_memory,             'Free MM Resource/Swapout:'],
{ 21 } [jsc$ti_sfd_freed,               '  .. Free also freed SFD:'],
{ 22 } [jsc$ti_free_readied_s2_job,     '    Freed S2 readied Job:'],
{ 23 } [jsc$ti_recalculate_sje,         ' Recalc SJE - Job Shared:'],
{ 24 } [jsc$ti_recal_sje_s0,            '    Recalculate SJE - S0:'],
{ 25 } [jsc$ti_recal_sje_s2,            '    Recalculate SJE - S2:'],
{ 26 } [c$no_index,                     '                         '],
{ 27 } [c$no_index,                     '           ABORT SWAP OUT'],
{ 28 } [jsc$ti_sif_idle_tasks_init,     '   Waiting Tasks To Idle:'],
{ 29 } [jsc$ti_sif_wait_state,          '             Wait States:'],
{ 30 } [jsc$ti_cd_idle_task_complete,   ' Swapin @ Idle Task Comp:'],
{ 31 } [jsc$ti_cd_idle_task_complete_2, 'Swapin @ Idle Task Comp2:'],
{ 32 } [jsc$ti_cd_to_in_at_s2,          'Swapin @ S2/Swap IO Comp:'],
{ 33 } [jsc$ti_cd_to_in_at_s,           '   Swapin @ Swapout Comp:'],
{ 34 } [jsc$ti_sif_swapout_io_init,     'Swapin while Swap IOInit:'],
{ 35 } [jsc$ti_swapout_io_error,        '        Swapout IO Error:'],
{ 36 } [jsc$ti_dm_transient_error,      'DM Transient Error/Alloc:'],
{ 37 } [c$no_index,                     '                         '],
{ 38 } [c$no_index,                     '   RESET SDT/XCB @ SWAPIN'],
{ 39 } [jsc$ti_rxcb_temp_asids_changed, 'Templ ASID change Swappd:'],
{ 40 } [jsc$ti_rxcb_job_asids_changed,  'Job ASID changed Swapped:'],
{ 41 } [jsc$ti_rxcb_glob_asids_changed, 'Global ASID change Swapp:'],
{ 42 } [jsc$ti_rxcb_fix_xcb_sdt,        'Tot XCBs scan SDT update:'],
{ 43 } [jsc$ti_rxcb_fix_asids,          'ASIDs need to be fixed  :'],
{ 44 } [jsc$ti_rxcb_fix_templ_asid,     'Fix Template ASID       :'],
{ 45 } [jsc$ti_rxcb_fix_jf_asid,        'Fix Job Fixed ASID      :'],
{ 46 } [jsc$ti_rxcb_fix_job_asid,       'Fix Permanent File ASID :'],
{ 47 } [jsc$ti_rxcb_zero_job_asid,      'Zero out Perm File ASID :'],
{ 48 } [jsc$ti_rxcb_recovery,           'Swapins after Job Recov :'],
{ 49 } [jsc$ti_rxcb_zero_asid,          'Zero out ASID in Seg Tab:']];

    VAR
      v$screen_definitions_right: [READ, oss$job_paged_literal] array [c$first_data_line .. c$last_data_line]
            of t$screen_definition := [
{ 01 } [c$no_index,                     '                         '],
{ 02 } [c$no_index,                     '                  SWAP IN'],
{ 03 } [jsc$ti_swapping_queue_and_exec, 'Advance Swap from R -> R:'],
{ 04 } [jsc$ti_swapin_from_job_mode,    '       Swapin Request JM:'],
{ 05 } [jsc$ti_swapin_from_mtr_mode,    '       Swapin Request MM:'],
{ 06 } [jsc$ti_swapin_mtr_direct,       'Swapin Request MM S0 - R:'],
{ 07 } [jsc$ti_swapin_req_status_bad,   '   Swapin bad on advance:'],
{ 08 } [jsc$ti_sif_idled_tasks_comp,    '   Swapin from Idle Task:'],
{ 09 } [jsc$ti_no_ajlo_swapin_before_io,'No AJLO Swapin before IO:'],
{ 10 } [jsc$ti_no_ajlo_swapin_after_io, ' No AJLO Swapin after IO:'],
{ 11 } [jsc$ti_no_ajlo_mtr_swapin,      '  No AJLO Swapin Monitor:'],
{ 12 } [c$no_index,                     '                         '],
{ 13 } [c$no_index,                     '  CLAIM PAGES FOR SWAP IN'],
{ 14 } [jsc$ti_no_memory_for_swap_in,   '      Failed - No Memory:'],
{ 15 } [jsc$ti_new_job_fixed_asid,      'No Reclaim-ASID Reassign:'],
{ 16 } [jsc$ti_reuse_job_fixed_asid,    '  Reclaim ASID Job Fixed:'],
{ 17 } [jsc$ti_reuse_job_fixed_asid_as, 'Reclaim old ASID Job Fix:'],
{ 18 } [jsc$ti_no_pages_for_sfd_on_si,  'Failed - No Page for SFD:'],
{ 19 } [jsc$ti_no_mem_from_claim_pages, 'No Memory from Claim Pag:'],
{ 20 } [jsc$ti_swapin_io_error,         '         Swapin IO Error:'],
{ 21 } [jsc$ti_swapin_int_by_swapout,   '  Swapin Init by Swapout:'],
{ 22 } [jsc$ti_free_memory_si_aborted,  'Free MM resourc IN Abort:'],
{ 23 } [jsc$ti_no_ajl_ord_for_swap_in,  ' No AJLO at Swapin Abort:'],
{ 24 } [c$no_index,                     '                         '],
{ 25 } [c$no_index,                     'CHANGE ASID DURING SWAPIN'],
{ 26 } [jsc$ti_change_asid,             ' Nr ASIDs changed in SFD:'],
{ 27 } [jsc$ti_change_asid_again,       '  ASIDs change in SFD 2*:'],
{ 28 } [jsc$ti_change_asid_sfd,         'Nr Pages w. ASID changed:'],
{ 29 } [c$no_index,                     '                         '],
{ 30 } [c$no_index,                     ' RESET JOB TABLES SWAPIN:'],
{ 31 } [jsc$ti_rmmt_no_change,          '       No Change in ASID:'],
{ 32 } [jsc$ti_rmmt_pf,                 'ASID Change of PF in JWS:'],
{ 33 } [jsc$ti_rmmt_pf_rec_ptm,         'Mod PF assg new ASID Rec:'],
{ 34 } [jsc$ti_rmmt_pf_rec_ptu,         'Discard PF Page Recovery:'],
{ 35 } [jsc$ti_rmmt_pf_assign_asid,     'PF assg new ASID - DM no:'],
{ 36 } [jsc$ti_rmmt_pf_reuse_asid,      'PF ASID reassg - from DM:'],
{ 37 } [jsc$ti_rmmt_lf_assign_asid,     '  Assign ASID Local File:'],
{ 38 } [jsc$ti_rmmt_lf_reuse_asid,      '   Reuse ASID Local File:'],
{ 39 } [jsc$ti_rmmt_pt_done,            'Page Table Entry Success:'],
{ 40 } [jsc$ti_rmmt_pt_full,            '         Page Table Full:'],
{ 41 } [jsc$ti_rmmt_pt_full_failed,     '  Page Table Full Failed:'],
{ 42 } [jsc$ti_rmmt_pt_full_succ,       '    New ASID due PT Full:'],
{ 43 } [jsc$ti_rmmt_pte_exists_pf,      ' PTE exists by other Job:'],
{ 44 } [jsc$ti_rmmt_pte_exists_am,      ' PTE exists in Avail Mod:'],
{ 45 } [jsc$ti_rmmt_pte_exists_a,       ' PTE exists in Available:'],
{ 46 } [jsc$ti_rmmt_pte_exists_err,     '   PTE exists in Error Q:'],
{ 47 } [jsc$ti_pt_full_reassign_jf,     'PTE Reassig ASID Job Fix:'],
{ 48 } [c$no_index,                     '                         '],
{ 49 } [jsc$ti_pager_io_error,          ' IO Reject from Pager IO:']];

?? FMT (FORMAT := ON) ??

    TYPE
      t$display_data = array [jsc$ti_min_index .. jsc$ti_max_index] of integer;

    VAR
      v$previous_display_data_p: [STATIC, oss$task_shared] ^t$display_data := NIL,
      v$system_line_info: [STATIC, oss$task_shared] ^oft$system_line_info := NIL;

    VAR
      data: t$display_data,
      display_control: clt$display_control,
      i: integer,
      inc: integer,
      str: array [c$first_line .. c$last_line] of string (80),
      tot: integer;

?? NEWTITLE := 'P$ABORT_HANDLER', EJECT ??

{ PURPOSE:
{   This procedure provides clean-up processing when a task abort occurs.

    PROCEDURE p$abort_handler
      (    condition: pmt$condition;
           condition_information_p: ^pmt$condition_information;
           save_area_p: ^ost$stack_frame_save_area;
       VAR handler_status: ost$status);

      VAR
        ignore_status: ost$status;

      IF wid = 0 THEN
        clp$close_display (display_control, ignore_status);
      IFEND;

    PROCEND p$abort_handler;
?? OLDTITLE ??
?? EJECT ??
    status.normal := TRUE;

    IF wid = 0 THEN
      osp$establish_block_exit_hndlr (^p$abort_handler);
    IFEND;
    IF initial_call THEN
      ofp$open_display (file_name, wid, dpc$wc_sharing, dpc$wk_table, title, display_control, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
    IFEND;

{ Establish base values for the general statistics display if they do not already exist.
    IF v$system_line_info = NIL THEN
      ALLOCATE v$system_line_info IN osv$task_shared_heap^;
      v$system_line_info^.initialized := FALSE;
    IFEND;

    IF (total_display = FALSE) AND (v$previous_display_data_p = NIL) THEN
      ALLOCATE v$previous_display_data_p IN osv$task_shared_heap^;
      FOR i := c$first_data_line TO c$last_line DO
        IF v$screen_definitions_left [i].index <>  c$no_index THEN
          v$previous_display_data_p^ [v$screen_definitions_left [i].index] := 0;
        IFEND;
        IF v$screen_definitions_right [i].index <> c$no_index THEN
          v$previous_display_data_p^ [v$screen_definitions_right [i].index] := 0;
        IFEND;
      FOREND;
    IFEND;

    ofp$build_system_line (v$system_line_info^, str [c$system_line_info]);
    IF total_display THEN
      FOR i := c$first_data_line TO c$last_line DO
        str [i] (1, 40) := v$screen_definitions_left [i].description;
        IF v$screen_definitions_left [i].index <>  c$no_index THEN
          pmp$binary_to_ascii_fit (jsv$swap_trace [v$screen_definitions_left [i].index], 10, 10, 10, str [i]
                (27, 10));
        IFEND;

        str [i] (41, 40) := v$screen_definitions_right [i].description;
        IF v$screen_definitions_right [i].index <> c$no_index THEN
          pmp$binary_to_ascii_fit (jsv$swap_trace [v$screen_definitions_right [i].index], 10, 10, 10,
                str [i] (67, 10));
        IFEND;
      FOREND;
    ELSE
      FOR i := c$first_data_line TO c$last_line DO
        str [i] (1, 40) := v$screen_definitions_left [i].description;
        IF v$screen_definitions_left [i].index <>  c$no_index THEN
          tot := jsv$swap_trace [v$screen_definitions_left [i].index];
          inc := tot - v$previous_display_data_p^ [v$screen_definitions_left [i].index];
          v$previous_display_data_p^ [v$screen_definitions_left [i].index] := tot;
          pmp$binary_to_ascii_fit (inc, 10, 10, 10, str [i] (27, 10));
        IFEND;

        str [i] (41, 40) := v$screen_definitions_right [i].description;
        IF v$screen_definitions_right [i].index <> c$no_index THEN
          tot := jsv$swap_trace [v$screen_definitions_right [i].index];
          inc := tot - v$previous_display_data_p^ [v$screen_definitions_right [i].index];
          v$previous_display_data_p^ [v$screen_definitions_right [i].index] := tot;
          pmp$binary_to_ascii_fit (inc, 10, 10, 10, str [i] (67, 10));
        IFEND;
      FOREND;
    IFEND;

{ Display the results.
    IF wid <> 0 THEN
      dpp$clear_window (wid, status);
      FOR i := c$first_line TO c$last_line DO
        dpp$put_next_line (wid, str [i], status);
        IF NOT status.normal THEN
          RETURN; {----->
        IFEND;
      FOREND
    ELSE
      FOR i := c$first_line TO c$last_line DO
        clp$put_display (display_control, str [i], clc$trim, status);
        IF NOT status.normal THEN
          RETURN; {----->
        IFEND;
      FOREND;
      clp$close_display (display_control, status);
      osp$disestablish_cond_handler;
    IFEND;

  PROCEND p$swap_trace_statistics_display;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] OFP$SWAP_TRACE_STAT_INC_DISP', EJECT ??

  PROCEDURE [XDCL] ofp$swap_trace_stat_inc_disp
    (    wid: dpt$window_id;
         display_name: ost$name;
         file_name: amt$local_file_name;
         initial_call: boolean;
     VAR status: ost$status);

    VAR
      c$title: [READ, oss$job_paged_literal] string (33) := 'Swap Trace Statistics Incremental';

    p$swap_trace_statistics_display (c$title, FALSE {= inc} , wid, display_name, file_name, initial_call,
          status);

  PROCEND ofp$swap_trace_stat_inc_disp;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] OFP$SWAP_TRACE_STAT_TOTAL_DISP', EJECT ??

  PROCEDURE [XDCL] ofp$swap_trace_stat_total_disp
    (    wid: dpt$window_id;
         display_name: ost$name;
         file_name: amt$local_file_name;
         initial_call: boolean;
     VAR status: ost$status);

    VAR
      c$title: [READ, oss$job_paged_literal] string (27) := 'Swap Trace Statistics Total';

    p$swap_trace_statistics_display (c$title, TRUE {= total} , wid, display_name, file_name, initial_call,
          status);

  PROCEND ofp$swap_trace_stat_total_disp;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] OFP$SWAP_STATE_STAT_INC_DISP', EJECT ??

  PROCEDURE [XDCL] ofp$swap_state_stat_inc_disp
    (    wid: dpt$window_id;
         display_name: ost$name;
         file_name: amt$local_file_name;
         initial_call: boolean;
     VAR status: ost$status);

    VAR
      c$title_1: [READ, oss$job_paged_literal] string (33) := 'Swap State Statistics Incremental',
      c$title_2: [READ, oss$job_paged_literal] string (54) :=
            ' Transition   Count   Aver-us  Count/Sec        Max-us';

    p$swap_state_statistics_display (c$title_1, c$title_2, FALSE {= incremental} , wid, display_name,
          file_name, initial_call, status);

  PROCEND ofp$swap_state_stat_inc_disp;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] OFP$SWAP_STATE_STAT_TOTAL_DISP', EJECT ??

  PROCEDURE [XDCL] ofp$swap_state_stat_total_disp
    (    wid: dpt$window_id;
         display_name: ost$name;
         file_name: amt$local_file_name;
         initial_call: boolean;
     VAR status: ost$status);

    VAR
      c$title_1: [READ, oss$job_paged_literal] string (27) := 'Swap State Statistics Total',
      c$title_2: [READ, oss$job_paged_literal] string (54) :=
            ' Transition   Count  Total-us  Count            Max-us';

    p$swap_state_statistics_display (c$title_1, c$title_2, TRUE {= total} , wid, display_name, file_name,
          initial_call, status);

  PROCEND ofp$swap_state_stat_total_disp;
?? OLDTITLE ??
MODEND ofm$swap_statistics_display;
