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 /* format: style2,indcomtxt */
13 
14 change_dtem:
15      proc (a_ep);
16 
17 /**** Coded by E. Stone Nov. 1975 to KST re-do.
18       This procedure to called by any directory control
19       primitive to assure that the dtem of a branch is
20       altered.  The caller has changed to value of an
21       attribute in a directory entry which affects the
22       data in the KST entry for that segment, e.g. access,
23       ring brackets.  Usually the new dtem will be set
24       to the storage system time equivalent of the current
25       clock reading immediately.  If the clock reading equals
26       the dtem, the dtem is incremented by 1.  Care is taken
27       that dtem does not go too far in the future and
28       that the value of the dtem always increases.
29       If necessary the clock is read until these conditions are met.
30       If the old time is manifestly out to lunch, bad_dir_ is signalled. */
31 /* Modified 83-12-22 BIM for bad_dir_ signal */
32 
33           dcl     a_ep                   ptr;
34           dcl     continue               bit (1) aligned;
35           dcl     i                      fixed bin;
36           dcl     (old_dtem, new_dtem)   fixed bin (36);
37           dcl     time                   fixed bin (71);
38           dcl     1 CLOCK                aligned like clock_value;
39           dcl     1 OLD_DTEM             aligned like clock_value;
40           dcl     clock                  builtin;
41           dcl     bin                    builtin;
42           dcl     bad_dir_               condition;
43 
44 %page;
45 %include system_clock_value_;
46 %include dir_entry;
47 ^L
48           ep = a_ep;                                        /* copy entry pointer */
49           old_dtem = bin (ep -> entry.dtem, 36);            /* save current dtem for fast comparison */
50           unspec (OLD_DTEM) = ""b;
51           OLD_DTEM.fs_time = ep -> entry.dtem;
52           unspec (time) = unspec (OLD_DTEM);
53           if (time - clock ()) > 2 * 1000 * 1000            /* 2 seconds */
54           then signal bad_dir_;                             /* dtem cannot possibly be that far off */
55 
56           continue = "1"b;                                  /* set flag so that loop is executed at least once */
57 
58           do while (continue);
59                continue = "0"b;                             /* usually will change dtem without further ado */
60                time = clock ();
61                unspec (CLOCK) = unspec (time);              /* unspec (clock()) not valid */
62                new_dtem = bin (CLOCK.fs_time, 36);
63                if new_dtem ^> old_dtem
64                then do;                                     /* must take atypical action */
65                          if (new_dtem + 5) < old_dtem
66                          then /* if branch dtem has gone too far in future */
67                               continue = "1"b;              /* read clock again */
68                          else new_dtem = old_dtem + 1;      /* otherwise or if equal just increment */
69                     end;
70           end;
71           ep -> entry.dtem = bit (new_dtem, 36);            /* set new and different dtem */
72      end change_dtem;