1
2
3
4
5
6
7
8
9
10
11
12
13 grab_aste: procedure (segptr, a_len, rcode) returns (ptr);
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 dcl (segptr,
29 a_astep) pointer;
30
31 dcl (rcode,
32 code,
33 word) fixed bin (35);
34
35 dcl do_io bit (1);
36 dcl prewithdraw bit (1);
37 dcl segno fixed bin (17);
38 dcl dp ptr;
39
40 dcl (null, baseno, ptr, fixed) builtin;
41
42 dcl based_word (0:262143) fixed bin (35) based;
43 dcl (len, a_len) fixed bin (18);
44 dcl pno fixed bin;
45
46 dcl error_table_$dirseg fixed bin (35) ext;
47
48 dcl sum$getbranch entry (ptr, bit (36) aligned, ptr, fixed bin (35)),
49 lock$unlock_ast entry,
50 activate entry (ptr, fixed bin (35)) returns (ptr),
51 lock$dir_unlock entry (ptr),
52 setfaults$cache entry (ptr, bit (1) aligned),
53 syserr entry options (variable),
54 syserr$error_code entry options (variable);
55
56
57 %include dir_entry;
58 %include aste;
59
60
61
62 do_io = "0"b;
63 prewithdraw = "0"b;
64 go to grab_join;
65
66 grab_aste_io: entry (segptr, a_len, rcode) returns (ptr);
67
68 do_io = "1"b;
69 prewithdraw = "0"b;
70 go to grab_join;
71
72 prewithdraw: entry (segptr, a_len, rcode) returns (ptr);
73
74 do_io = "0"b;
75 prewithdraw = "1"b;
76
77 grab_join:
78 segno = fixed (baseno (segptr), 17);
79
80 len = divide (a_len + 1023, 1024, 17, 0);
81
82
83 call sum$getbranch (segptr, (36)"1"b , ep, code);
84
85
86
87
88
89 if code ^= 0 then do;
90 rcode = code;
91 return (null());
92 end;
93 dp = ptr (ep, 0);
94 if ep -> entry.dirsw then do;
95 call lock$dir_unlock (dp);
96 rcode = error_table_$dirseg;
97 return (null());
98 end;
99
100 astep = activate (ep, code);
101
102
103 if astep = null then do;
104 call lock$dir_unlock (dp);
105 rcode = code;
106 return (null ());
107 end;
108
109 if astep -> aste.ehs then
110 call syserr (1, "grab_aste: Attempt to re-use seg ^o", segno);
111
112 astep -> aste.ddnp = "1"b;
113
114
115
116 call lock$unlock_ast;
117
118 if prewithdraw then pno = 1;
119 else pno = len;
120
121 do pno = pno to len by 1;
122 word = segptr -> based_word ((pno - 1) * 1024);
123
124 end;
125
126 astep = activate (ep, code);
127 if astep = null then call syserr$error_code (1, code, "grab_aste: failed to reactivate ^p", ep);
128
129 astep -> aste.ddnp = prewithdraw;
130
131 astep -> aste.ehs = "1"b;
132
133 if do_io then do;
134 astep -> aste.any_access_on = "0"b;
135 astep -> aste.write_access_on,
136 astep -> aste.inhibit_cache = "1"b;
137 call setfaults$cache (astep, "0"b);
138 end;
139
140 call lock$unlock_ast;
141 call lock$dir_unlock (dp);
142 rcode = 0;
143
144 return (astep);
145
146
147 release_io: entry (a_astep);
148 do_io = "1"b;
149 prewithdraw = "0"b;
150 go to release_join;
151
152 release_prewithdraw: entry (a_astep);
153
154 prewithdraw = "1"b;
155 do_io = "0"b;
156 go to release_join;
157
158 release: entry (a_astep);
159 do_io = "0"b;
160 prewithdraw = "0"b;
161
162 release_join:
163 astep = a_astep;
164 if ^astep -> aste.ehs then
165 call syserr (1, "grab_aste: Unprotected segment: astep = ^p", astep);
166
167 astep -> aste.ehs = "0"b;
168 if do_io then astep -> aste.inhibit_cache = "0"b;
169 if prewithdraw then astep -> aste.ddnp = "0"b;
170 return;
171 ^L
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216 end;