?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Job Management : Operator Commands' ??
MODULE jmm$oper_command_requests;

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clt$value
*copyc CLE$ECC_MISCELLANEOUS
*copyc CLE$ECC_PARAMETER_LIST
*copyc jmc$job_management_id
*copyc jme$job_scheduler_conditions
*copyc jmt$swapout_reasons
*copyc OST$STATUS
?? POP ??
*copyc clp$evaluate_parameters
*copyc CLP$SCAN_PARAMETER_LIST
*copyc CLP$GET_VALUE
*copyc CLP$GET_SET_COUNT
*copyc CLP$SCAN_PARAMETER_LIST
*copyc JMP$SWAPOUT_JOB
*copyc JMP$SWAPIN_JOB
*copyc jmp$test_for_system_idle
*copyc osp$set_status_abnormal
*copyc pmp$wait

?? TITLE := '[XDCL] jmp$oper_swapin_of_job ', EJECT ??

{ PDT swap_rqst_pdt (
{  JOB_NAME, JN: NAME = $REQUIRED
{  STATUS)


  VAR
    swap_rqst_pdt: [STATIC, READ, cls$pdt] clt$parameter_descriptor_table :=
      [^swap_rqst_pdt_names, ^swap_rqst_pdt_params];

  VAR
    swap_rqst_pdt_names: [STATIC, READ, cls$pdt_names_and_defaults] array [1 ..
      3] of clt$parameter_name_descriptor := [['JOB_NAME', 1], ['JN', 1], ['STATUS', 2]];

  VAR
    swap_rqst_pdt_params: [STATIC, READ, cls$pdt_parameters] array [1 .. 2] of
      clt$parameter_descriptor := [

{ JOB_NAME JN }
    [[clc$required], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL,
      clc$name_value, 1, osc$max_name_size]],

{ STATUS }
    [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL,
      clc$variable_reference, clc$array_not_allowed, clc$status_value]]];

  PROCEDURE [XDCL, #GATE] jmp$oper_swapin_of_job (parameter_list: clt$parameter_list;
    VAR status: ost$status);

    VAR
      job_name: clt$value;

    clp$scan_parameter_list (parameter_list, swap_rqst_pdt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$get_value ('JOB_NAME', 1, 1, clc$low, job_name, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    jmp$swapin_job (job_name, status);
  PROCEND jmp$oper_swapin_of_job;
?? TITLE := '[XDCL] jmp$oper_swapout_of_job ', EJECT ??

  PROCEDURE [XDCL, #GATE] jmp$oper_swapout_of_job (parameter_list: clt$parameter_list;
    VAR status: ost$status);

{ PROCEDURE (osm$swaoj) swap_out_job, swaoj (
{   job_name, jn: name = $REQUIRED
{   disable_recovery, dr: boolean = FALSE
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 5] of clt$pdt_parameter_name,
      parameters: array [1 .. 3] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$name_type_qualifier,
      recend,
      type2: record
        header: clt$type_specification_header,
        default_value: string (5),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [89, 2, 3, 11, 28, 7, 93],
    clc$command, 5, 3, 1, 0, 0, 0, 3, 'OSM$SWAOJ'], [
    ['DISABLE_RECOVERY               ',clc$nominal_entry, 2],
    ['DR                             ',clc$abbreviation_entry, 2],
    ['JN                             ',clc$abbreviation_entry, 1],
    ['JOB_NAME                       ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 3]],
    [
{ PARAMETER 1
    [4, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 5, clc$required_parameter, 0
  , 0],
{ PARAMETER 2
    [1, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_default_parameter, 0, 5],
{ PARAMETER 3
    [5, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$name_type], [1, osc$max_name_size]],
{ PARAMETER 2
    [[1, 0, clc$boolean_type],
    'FALSE'],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$job_name = 1,
      p$disable_recovery = 2,
      p$status = 3;

    VAR
      pvt: array [1 .. 3] of clt$parameter_value;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    jmp$swapout_job (pvt [p$job_name].value^.name_value, pvt [p$disable_recovery].value^.boolean_value.value,
          status);
  PROCEND jmp$oper_swapout_of_job;
?? TITLE := '[XDCL] jmp$display_sch_table ', EJECT ??

{ PURPOSE:
{   The purpose of this request is to display the attributes of the job scheduler
{   table.
{ NOTES:
{   This request is retained for compatibility.  It is replaced functionally by
{   commands under the ADMINISTER_SCHEDULING and MANAGE_ACTIVE_SCHEDULING utilities.

  PROCEDURE [XDCL] jmp$display_sch_table
    (    param_list: clt$parameter_list;
     VAR status: ost$status);

{ PDT dst_pdt (
{ output,o: FILE =$OUTPUT
{ STATUS);


  VAR
    dst_pdt: [STATIC, READ, cls$pdt] clt$parameter_descriptor_table :=
      [^dst_pdt_names, ^dst_pdt_params];

  VAR
    dst_pdt_names: [STATIC, READ, cls$pdt_names_and_defaults] array [1 .. 3] of clt$parameter_name_descriptor
      := [['OUTPUT', 1],
      ['O', 1],
      ['STATUS', 2]];

  VAR
    dst_pdt_params: [STATIC, READ, cls$pdt_parameters] array [1 .. 2] of clt$parameter_descriptor := [

{ OUTPUT O }
      [[clc$optional_with_default, ^dst_pdt_dv1],
      1, 1,
      1, 1,
      clc$value_range_not_allowed,
      [NIL,
      clc$file_value]],

{ STATUS }
      [[clc$optional],
      1, 1,
      1, 1,
      clc$value_range_not_allowed,
      [NIL,
      clc$variable_reference, clc$array_not_allowed, clc$status_value]]];

  VAR
    dst_pdt_dv1: [STATIC, READ, cls$pdt_names_and_defaults] string (7) := '$OUTPUT';

    clp$scan_parameter_list (param_list, dst_pdt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Issue a warning message stating that this command has been replaced by
{ the ADMINISTER_SCHEDULING and MANAGE_ACTIVE_SCHEDULING utilities.

    osp$set_status_abnormal (jmc$job_management_id, jme$use_adms_or_manas_utility, '', status);

  PROCEND jmp$display_sch_table;
?? TITLE := '[XDCL] jmp$change_scheduler_table_cmnd ', EJECT ??

{ PURPOSE:
{   The purpose of this request is to change the attributes of the job scheduler
{   table.
{ NOTES:
{   This request is retained for compatibility.  It is replaced functionally by
{   commands under the ADMINISTER_SCHEDULING and MANAGE_ACTIVE_SCHEDULING utilities.

  PROCEDURE [XDCL] jmp$change_scheduler_table_cmnd
    (    parm_list: clt$parameter_list;
     VAR status: ost$status);

{ PDT chast_pdt (
{ service_calc_interval,sci: INTEGER 1 .. 300
{ idle_dispatching_queue_time,idqt: INTEGER 10 .. 36000
{ target_memory,tm: INTEGER 0 .. 100000
{ thrashing_level,tl: INTEGER 0 .. 100000
{ STATUS);

?? PUSH (LISTEXT := ON) ??

  VAR
    chast_pdt: [STATIC, READ, cls$pdt] clt$parameter_descriptor_table := [^chast_pdt_names, ^chast_pdt_params
      ];

  VAR
    chast_pdt_names: [STATIC, READ, cls$pdt_names_and_defaults] array [1 .. 9] of
      clt$parameter_name_descriptor := [['SERVICE_CALC_INTERVAL', 1], ['SCI', 1], [
      'IDLE_DISPATCHING_QUEUE_TIME', 2], ['IDQT', 2], ['TARGET_MEMORY', 3], ['TM', 3], ['THRASHING_LEVEL', 4]
      , ['TL', 4], ['STATUS', 5]];

  VAR
    chast_pdt_params: [STATIC, READ, cls$pdt_parameters] array [1 .. 5] of clt$parameter_descriptor := [

{ SERVICE_CALC_INTERVAL SCI }
    [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$integer_value, 1, 300]],

{ IDLE_DISPATCHING_QUEUE_TIME IDQT }
    [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$integer_value, 10, 36000]],

{ TARGET_MEMORY TM }
    [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$integer_value, 0, 100000]],

{ THRASHING_LEVEL TL }
    [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$integer_value, 0, 100000]],

{ STATUS }
    [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$variable_reference,
      clc$array_not_allowed, clc$status_value]]];

?? POP ??

    clp$scan_parameter_list (parm_list, chast_pdt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Issue a warning message stating that this command has been replaced by
{ the ADMINISTER_SCHEDULING and MANAGE_ACTIVE_SCHEDULING utilities.

    osp$set_status_abnormal (jmc$job_management_id, jme$use_adms_or_manas_utility, '', status);

  PROCEND jmp$change_scheduler_table_cmnd;
?? TITLE := '[XDCL] jmp$wait_system_idle_comnd ', EJECT ??

  PROCEDURE [XDCL] jmp$wait_system_idle_comnd (param_list: clt$parameter_list;
                 VAR status: ost$status);


{ PDT wait_system_idle_pdt (
{   TIME, T: integer 0 .. 100000000 = $required
{   STATUS)

?? PUSH (LISTEXT := ON) ??

  VAR
    wait_system_idle_pdt: [STATIC, READ, cls$pdt] clt$parameter_descriptor_table := [
      ^wait_system_idle_pdt_names, ^wait_system_idle_pdt_params];

  VAR
    wait_system_idle_pdt_names: [STATIC, READ, cls$pdt_names_and_defaults] array [1 .. 3] of
      clt$parameter_name_descriptor := [['TIME', 1], ['T', 1], ['STATUS', 2]];

  VAR
    wait_system_idle_pdt_params: [STATIC, READ, cls$pdt_parameters] array [1 .. 2] of
      clt$parameter_descriptor := [

{ TIME T }
    [[clc$required], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$integer_value, 0, 100000000]],

{ STATUS }
    [[clc$optional], 1, 1, 1, 1, clc$value_range_not_allowed, [NIL, clc$variable_reference,
      clc$array_not_allowed, clc$status_value]]];

?? POP ??
   VAR
    time_left: integer,
    wait_ms: integer,
    value: clt$value,
    end_wait_time: integer;

    clp$scan_parameter_list(param_list, wait_system_idle_pdt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    clp$get_value ('TIME', 1, 1,clc$low, value, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    end_wait_time := 1000 * value.int.value + #free_running_clock (0);

    REPEAT
      jmp$test_for_system_idle (status);
      time_left := end_wait_time - #free_running_clock (0);
      IF NOT status.normal AND (time_left > 0) THEN
        wait_ms := time_left DIV 1000;
        pmp$wait (wait_ms, wait_ms);
      IFEND;
    UNTIL (time_left <= 0) OR status.normal;

  PROCEND jmp$wait_system_idle_comnd;
MODEND jmm$oper_command_requests;
