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 deactivate_segs: proc (a_pds_astep);
 14 
 15 /* DEACTIVATE_SEGS -- remove all traces of a stopped process from the system */
 16 
 17 /* Modified by R. Bratt 2/11/75 to lock the ast before attempting to delete trailers
 18    and to avoid attempting to delete trailers for hardcore segment numbers
 19    modified April 1975 by R. Bratt for new KST / RNT system
 20    modified April 1975 by R. Bratt for new access in KST / SDW scheme
 21    modified June 1976 by B. Greenberg to leave KST visible in trailer crashes.
 22    modified 06/76 by D. Vinograd to handle backup_abs_seg.
 23    modified Oct 31 76 by Greenberg for pc$truncate_deposit_all (stop losing dseg pages).
 24    modified 02/22/77 by THVV for dsegs with branches
 25    Modified 03/21/81, W. Olin Sibert, for ADP PTWs and get_ptrs_$given_sdw
 26    Modified 04/16/81, WOS, for sdw_util_, and to remove obsolete PDS unwiring code.
 27    Modified March 1982, J. Bongiovanni, to make sure KST exists before using it
 28    */
 29 
 30 dcl  a_pds_astep pointer parameter;
 31 
 32 dcl  asp pointer;                                           /* Pointer to abs_seg$ (overlays assorted segmets) */
 33 dcl  drsp pointer;                                          /* Pointer to dir_seg$ (overlays the dead KST) */
 34 dcl (dstep, kst_astep, pds_astep, seg_astep) pointer;       /* Assorted ASTEPs */
 35 dcl  tsdw fixed bin (71);
 36 dcl  tsdwp pointer;
 37 dcl  rdstep bit (18) aligned;
 38 dcl (highseg, hcscnt, rel_dstep, i) fixed bin;
 39 dcl  sdw_address fixed bin (26);
 40 dcl  sdwp pointer;
 41 
 42 dcl  bit18 bit (18) aligned based;
 43 dcl  based_ptr ptr based;
 44 dcl  sdwa (0 : 1023) fixed bin (71) aligned based;          /* DSEG overlay */
 45 
 46 dcl  abs_seg$ fixed bin external static;
 47 dcl  backup_abs_seg$ external static;
 48 dcl  dir_seg$ fixed bin ext external static;
 49 
 50 dcl  pds$dstep bit (18) external static;
 51 dcl  sst_seg$ external static;
 52 
 53 dcl  check_trailer entry (fixed bin) returns (bit (1) aligned);
 54 dcl  get_ptrs_$given_astep entry (ptr) returns (fixed bin (71));
 55 dcl  get_ptrs_$given_sdw entry (pointer) returns (pointer);
 56 dcl  grab_aste$release entry (ptr);
 57 dcl  grab_aste$release_prewithdraw entry (ptr);
 58 dcl  lock$lock_ast entry ();
 59 dcl  lock$unlock_ast entry ();
 60 dcl  pmut$swap_sdw entry (ptr, ptr);
 61 dcl  setfaults$deltrailer entry (ptr, fixed bin (17), fixed bin (17));
 62 dcl  sdw_util_$get_address entry (pointer, fixed bin (26));
 63 dcl  syserr entry options (variable);
 64 
 65 dcl (baseno, ptr, rel, addr, fixed, null) builtin;
 66 
 67 /* ^L */
 68 
 69           pds_astep = a_pds_astep;                          /* copy argument */
 70           asp = addr (abs_seg$);                            /* get needed pointers */
 71           drsp = addr (dir_seg$);
 72           tsdwp = addr (tsdw);
 73           tsdw = get_ptrs_$given_astep (pds_astep);         /* get pointer to PDS of process being deactivated */
 74           call pmut$swap_sdw (asp, tsdwp);                  /* make abs_seg point to the PDS */
 75 
 76           rdstep = ptr (asp, rel (addr (pds$dstep))) -> bit18; /* get dstep from the PDS */
 77           dstep = ptr (addr (sst_seg$), rdstep);            /* get a pointer to the DSEG ASTE */
 78           kstp = ptr (asp, rel (addr (pds$kstp))) -> based_ptr; /* get pointer in HIS process to KST */
 79 
 80           tsdw = get_ptrs_$given_astep (dstep);             /* look at the DSEG */
 81           call pmut$swap_sdw (asp, tsdwp);                  /* make the ABS-SEG work */
 82 
 83           if kstp ^= null () then do;
 84                kst_astep = get_ptrs_$given_sdw (addr (asp -> sdwa (fixed (baseno (kstp), 18))));
 85                tsdw = get_ptrs_$given_astep (kst_astep);    /* make abs_seg point to the KST */
 86                call pmut$swap_sdw (drsp, tsdwp);
 87                highseg = drsp -> kst.highest_used_segno;    /* copy highseg from the KST header */
 88                hcscnt = drsp -> kst.lowseg;                 /* get the hardcore seg count for later */
 89                call grab_aste$release (kst_astep);                    /* Release the KST aste */
 90           end;
 91 
 92 /* Used to unwire any wired PDS pages here, but since the PDS is no longer used as a ring zero stack,
 93    there is no need to do this any more. First page won't be wired, either, because process is stopped,
 94    and has been unloaded. */
 95 
 96           call grab_aste$release_prewithdraw (pds_astep);   /* Release the PDS aste */
 97 
 98           if kstp ^= null () then do;
 99                rel_dstep = fixed (rdstep, 18);              /* get rel(dstep) for deltrailer call */
100                tsdw = get_ptrs_$given_astep (dstep);        /* make the abs_seg point to the descriptor segment */
101                call pmut$swap_sdw (asp, tsdwp);
102                call lock$lock_ast;
103                do i = hcscnt + 1 to highseg,                /* loop through the KST entries */
104                     fixed (baseno (addr (backup_abs_seg$)), 18); /* And the backup_abs_seg, just in case */
105 
106                     sdwp = addr (asp -> sdwa (i));
107                     call sdw_util_$get_address (sdwp, sdw_address);
108                     if sdw_address ^= 0 then do;
109                          seg_astep = get_ptrs_$given_sdw (sdwp);
110                          call setfaults$deltrailer (seg_astep, i, rel_dstep); /* delete the trailer */
111                     end;
112                end;
113 
114 /* this check has been disabled for efficiency considerations, and beecause the
115    class of software problems which caused it to go off have all been fixed.
116    It should be made enablable by a tuning parameter if it is felt to be
117    needed in the future.
118    */
119 
120                if "0"b then
121                     if check_trailer (rel_dstep) then
122                          call syserr (1, "deactivate_segs: unflushed trailer");
123 
124                call lock$unlock_ast;
125           end;
126 
127 /* Done with dseg */
128 
129           call grab_aste$release_prewithdraw (dstep);       /* release the DSEG aste */
130 
131           tsdw = 0;
132           call pmut$swap_sdw (asp, tsdwp);                  /* Clean up dseg */
133           call pmut$swap_sdw (drsp, tsdwp);
134           return;
135 
136 %page; %include aste;
137 %page; %include kst;
138 
139 /* ^L */
140 
141 /* BEGIN MESSAGE DOCUMENTATION
142 
143    Message:
144    deactivate_segs: unflushed trailer
145 
146    S: $crash
147 
148    T: $run
149 
150    M: After destroying a process, the system found that some system trailer
151    (specifying connection of that process to some segment) still exists
152    for that process in str_seg. This indicates that some segment was
153    improperly disconnected from the process at some time. $err
154 
155    A: $recover
156 
157    END MESSAGE DOCUMENTATION */
158 
159      end deactivate_segs;