1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  6         *                                                         *
  7         * Copyright (c) 1972 by Massachusetts Institute of        *
  8         * Technology and Honeywell Information Systems, Inc.      *
  9         *                                                         *
 10         *********************************************************** */
 11 
 12 
 13 deact_proc: proc;
 14 
 15 /* Changed by E Stone to remove destroy entry and to convert to v2 on 05/74 */
 16 /* Modified 05/78 by J. A. Bush to add cleanup for processor testing */
 17 /* Modified September 1981 by J. Bongiovanni for tc_util */
 18 
 19 dcl  code fixed bin (35);
 20 
 21 dcl  save_ring fixed bin (3),                               /* validation level */
 22     (sstp, pds_astep) ptr,
 23      name char (32) aligned;
 24 
 25 dcl  delentry$dfile entry (char (*) aligned, char (*) aligned, fixed bin (35)),
 26      del_dir_tree entry (char (*) aligned, char (*) aligned, fixed bin (35)),
 27      unique_chars_ entry (bit (*) aligned) returns (char (15) aligned),
 28      level$get entry returns (fixed bin (3)),
 29      level$set entry (fixed bin (3)),
 30      pxss$stop_wakeup entry (bit (36) aligned, fixed bin),
 31      tc_util$process_status entry (ptr),
 32      pxss$empty_t ext entry (ptr),
 33      deactivate_segs ext entry (ptr),
 34      reconfig$destroy_cpu_test_env entry,
 35      ioam_$process_release entry (bit (36) aligned);
 36 
 37 dcl  error_table_$action_not_performed fixed bin (35) ext,
 38      sst_seg$ fixed bin ext;
 39 
 40 dcl (addr, ptr) builtin;
 41 
 42 dcl 1 process_info based (pi_ptr) aligned,                  /* structure used to transfer accounting data */
 43     2 processid bit (36),
 44     2 page_faults fixed bin (35),
 45     2 aptep ptr,
 46     2 ex_state fixed bin,
 47     2 mp_state fixed bin,
 48     2 last_block_time fixed bin (71),
 49     2 cpu_time_used fixed bin (71),
 50     2 paging_measure fixed bin (71),
 51     2 virtual_cpu_time fixed bin (71),
 52     2 reserved fixed bin (71);
 53 
 54 dcl 1 info aligned like process_info;
 55 
 56 
 57 
 58 
 59 
 60           % include apte;
 61 % include scs;
 62 
 63 /* ^L */
 64 
 65 /* The entry destroy_process_begin initiates the destruction of a process by stopping it
 66    in such a way that when the process stops it will send a wakeup to the process specified
 67    in apte.term_processid. The wakeup will be over the channel apte.term_channel. When the wakeup
 68    is received by the driving process (Answering Service?) the entry destroy_process_finish
 69    is called to return the final process statistics and to clean up the APT entry.
 70    As a final step destroy_process_finish deletes the process directory of the
 71    process just destroyed. */
 72 
 73 destroy_process_begin: entry (pi_ptr, code);
 74 
 75 dcl  pi_ptr ptr;
 76 
 77           info.processid = pi_ptr -> process_info.processid; /* get ID OF PROCESS TO STOP */
 78           call pxss$stop_wakeup (info.processid, info.ex_state); /* stop it */
 79           if info.ex_state = 0 then code = error_table_$action_not_performed;
 80           else code = 0;                                    /* return non-zero code only if already stopped */
 81           return;
 82 
 83 /* * * * * * * *  * * * * * * * * * * * * * * * */
 84 
 85 destroy_process_finish: entry (pi_ptr, code);
 86 
 87           info.processid = pi_ptr -> process_info.processid; /* get the process ID */
 88           call tc_util$process_status (addr (info));                  /* get the goods for the process */
 89                                                             /* check for stopped process */
 90           if ^((info.ex_state = 5) & (info.mp_state = 1)) then do;
 91                code = error_table_$action_not_performed;    /* return non-zero code only if not stopped */
 92                return;
 93           end;
 94           sstp = addr (sst_seg$);
 95           pds_astep = ptr (sstp, info.aptep -> apte.asteps.pds); /* get pointer to pds for the process */
 96           call deactivate_segs (pds_astep);                 /* deactivate the process */
 97           info.aptep -> apte.lock_id = ""b;                 /* clear out the lock id */
 98           info.aptep -> apte.processid = ""b;               /* and the process id */
 99           call pxss$empty_t (info.aptep);                   /* give back the APT entry */
100           call ioam_$process_release (info.processid);      /* free any devices assigned to this process */
101           if scs$reconfig_lock = info.processid then        /* is this process testing a processor? */
102                call reconfig$destroy_cpu_test_env;          /* release CPU and SCU resources */
103           name = unique_chars_ (info.processid);            /* get the PDIR name */
104           save_ring = level$get ();                         /* get (save) the validation level */
105           call level$set (0);                               /* do del_dir_tree from ring 0 */
106           call del_dir_tree (">process_dir_dir", name, code);
107           if code = 0 then
108                call delentry$dfile (">process_dir_dir", name, code);
109           call level$set (save_ring);                       /* restore validation level */
110           pi_ptr -> process_info = info;                    /* copy back accounting information */
111           return;
112 
113      end deact_proc;