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 /*
 14                               deactivate (astep, code)
 15                               deactivate$for_delete (astep, code)
 16 
 17 
 18 
 19 FUNCTION -
 20 
 21 The procedure "deactivate" deactivates the segment whose ASTE is pointed  to  by
 22 the  input argument "astep".  If the deactivation is successful, it returns with
 23 code=0; if the deactivation fails, it returns with code=0, or ehs=1.
 24 
 25 The procedure "deactivate" does not concern itself with the AST lock. It assumes
 26 there is no race condition.  It is the responsibility of the caller to make sure
 27 there is no race condition. The initializer  or  shutdown  of  course  may  call
 28 deactivate  without  locking  the AST. For normal processes, however, the caller
 29 must make sure the AST is locked before the call  is  issued,  and  it  will  be
 30 unlocked upon return as soon as it is safe to do so.
 31 
 32 The  ASTE  is  left  in  the  circular list associated with the size of the page
 33 table, at the first position, so that it will be found right away should an ASTE
 34 of this size be needed.
 35 
 36 The ASTE is removed from the uid hash table.
 37 
 38 All items of the ASTE are zeroed except fp, bp, ptsi and marker. All  PTW's  are
 39 initialized with a page not in core flag and a coded null disk address.
 40 
 41 deactivate$for_delete does not update the VTOCE
 42 
 43 MODIFICATIONS -
 44 
 45 10/13/82  J. Bongiovanni, to check number of pages in core after cleanup
 46 09/17/82  J. Bongiovanni, for deactivate$for_delete
 47 03/21/81  W. Olin Sibert, for ADP PTWs (or, rather, lack of them in this program)
 48 04/19/81  W. Olin Sibert   - Eliminated maintenance of aste.ic
 49 11/18/80  E. N. Kittlitz   - Modified for new dtu/dtm calculation.
 50 04/10/75  Andre Bensoussan - Modified for the new storage system.
 51 
 52 */
 53 
 54 
 55 ^L
 56 deactivate        : proc  (a_astep, a_code);
 57 
 58 dcl  a_astep        ptr,
 59      a_code         fixed bin (35);
 60 
 61 
 62 
 63 dcl  pastep         ptr,
 64     (last, relp)    bit (18) aligned,
 65      code           fixed bin (35),
 66      for_delete_call
 67                     bit (1);
 68 
 69 
 70 
 71 dcl (error_table_$illegal_deactivation, error_table_$deact_in_mem)    fixed bin (35) ext;
 72 
 73 dcl sst_seg$ external static;
 74 dcl  sst$deact_count fixed bin (35) external static;
 75 dcl sstp pointer;
 76 
 77 dcl
 78      pc$cleanup               entry (ptr),
 79      setfaults                entry (ptr, bit(1) aligned),
 80      update_vtoce$deact       entry (ptr, fixed bin (35)),
 81      put_aste                 entry (ptr),
 82      search_ast$hash_out      entry (ptr);
 83 
 84 dcl (addr, binary, bit, fixed, max, ptr, rel) builtin;
 85 
 86 /* ^L */
 87 
 88           for_delete_call = "0"b;
 89           goto COMMON;
 90 
 91 for_delete:
 92           entry (a_astep, a_code);
 93 
 94           for_delete_call = "1"b;
 95 
 96 COMMON:
 97 
 98           a_code = 0;                                       /* zero return code */
 99           sstp   = addr (sst_seg$);                         /* get a pointer to the SST */
100           astep  = a_astep;                                 /* copy arguments */
101 
102           if (aste.infp ^= ""b) | aste.ehs | (aste.par_astep = ""b) | fixed (aste.np, 9) > 256 then do;
103                a_code = error_table_$illegal_deactivation;
104                return;
105                end;
106 
107           call setfaults (astep, "0"b);                     /* set faults in all SDW's */
108 
109           call pc$cleanup (astep);                          /* cleanup the segment (page control) */
110           if aste.np ^= ""b then do;                        /* cleanup failed */
111                a_code = error_table_$deact_in_mem;
112                return;
113           end;
114 
115           if ^for_delete_call then do;
116                call update_vtoce$deact (astep, code);       /* update the vtoc entry */
117                if code ^= 0 then do;
118                     a_code = code;
119                     return;
120                end;
121           end;
122 
123 
124           pastep = ptr (sstp, astep -> aste.par_astep);     /* get a pointer to the parent AST entry */
125 
126           last = "0"b;                                      /* delete the entry from the list of inferior entries */
127           relp = pastep -> aste.infp;                       /* get pointer to inferior chain */
128           do while (relp ^= rel(astep));                    /* loop until end of list (shouldn't get to end ^= rel(astep)) */
129                last = relp;                                 /* go to next entry (but save pointer to previous one) */
130                relp = ptr (sstp, relp) -> aste.infl;
131           end;
132           if last = "0"b then pastep -> aste.infp = astep -> aste.infl;
133                else ptr (sstp, last) -> aste.infl = astep -> aste.infl;
134 
135                                                             /* set dtu of parent to smallest reasonable value */
136           pastep -> aste.dtu = bit (max (binary (pastep -> aste.dtu, 36),
137                binary (pastep -> aste.dtm, 36), binary (astep -> aste.dtu, 36)), 36);
138 
139           call search_ast$hash_out (astep);
140 
141           call put_aste (astep);
142 
143           sst$deact_count = sst$deact_count + 1; /* meter */
144 
145           return;
146 
147 %page; %include aste;
148 
149      end deactivate;