1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 tc_util:
16 proc;
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 dcl a_allow_special_procs
81 bit (1) aligned;
82 dcl a_code fixed bin (35) parameter;
83 dcl a_delta_vcpu fixed bin (71) parameter;
84 dcl a_info_ptr ptr;
85 dcl a_ips_signal_name char (*);
86 dcl a_processid bit (36) aligned parameter;
87 dcl a_timax fixed bin (35) parameter;
88 dcl P_ipc_r_offset fixed bin (18) parameter;
89 dcl P_ipc_r_factor fixed bin (35) parameter;
90
91
92
93 dcl arg_list_ptr ptr;
94 dcl code fixed bin (35);
95 dcl delta_vcpu fixed bin (71);
96 dcl ipc_r_offset fixed bin (18);
97 dcl ipc_r_factor fixed bin (35);
98 dcl ips_mask_index fixed bin;
99 dcl ips_signal_name char (32);
100 dcl oldmask fixed bin (71);
101 dcl process_mp_state fixed bin;
102 dcl process_state fixed bin;
103 dcl process_timax fixed bin (35);
104 dcl processid bit (36) aligned;
105 dcl ptwp ptr;
106
107
108
109 dcl 1 a_process_status aligned based (a_info_ptr) like process_status_return;
110 dcl 1 my_arg_list aligned based (arg_list_ptr) like arg_list;
111
112
113
114 dcl cu_$arg_list_ptr entry (ptr);
115 dcl lock$lock_fast entry (ptr);
116 dcl lock$unlock_fast entry (ptr);
117 dcl pmut$wire_and_mask entry (fixed bin (71), ptr);
118 dcl pmut$unwire_unmask entry (fixed bin (71), ptr);
119 dcl pxss$lock_apte entry (bit (36) aligned, ptr, fixed bin (35));
120 dcl pxss$ips_wakeup entry (bit (36) aligned, bit (36) aligned);
121 dcl pxss$suspend_getwork
122 entry ();
123 dcl pxss$unlock_apte entry (ptr);
124 dcl signal_ entry options (variable);
125 dcl wire_proc$unwire_me entry;
126 dcl wire_proc$wire_me entry;
127
128
129
130 dcl error_table_$quit_term_abort
131 fixed bin (35) external;
132 dcl error_table_$process_unknown
133 fixed bin (35) external;
134 dcl pds$apt_ptr ptr external;
135 dcl tc_data$ external;
136 dcl tc_data$abort_ips_mask
137 bit (36) aligned external;
138 dcl tc_data$apt bit (36) aligned external;
139 dcl tc_data$apt_size fixed bin external;
140 dcl tc_data$tc_suspend_lock
141 bit (36) aligned external;
142 dcl tc_data$timax fixed bin (35) external;
143
144
145
146
147 dcl addr builtin;
148 dcl bin builtin;
149 dcl divide builtin;
150 dcl mod builtin;
151 dcl null builtin;
152 dcl ptr builtin;
153 dcl rel builtin;
154 dcl size builtin;
155 dcl unspec builtin;
156
157 return;
158
159 %page;
160
161
162
163 check_abort:
164 entry (a_code);
165
166 a_code = 0;
167
168 aptep = pds$apt_ptr;
169 if apte.flags.stop_pending | ((apte.ips_message & tc_data$abort_ips_mask) ^= ""b)
170 then a_code = error_table_$quit_term_abort;
171
172 return;
173 %page;
174
175
176
177
178
179 get_aptep:
180 entry (a_processid, a_allow_special_procs) returns (ptr);
181
182 aptep = PROCESSID_TO_APTE ((a_processid), (a_allow_special_procs));
183 return (aptep);
184 %page;
185
186
187
188
189
190
191 ips_wakeup:
192 entry (a_processid, a_ips_signal_name);
193
194
195
196
197
198
199 call cu_$arg_list_ptr (arg_list_ptr);
200 if my_arg_list.header.desc_count = 0
201 then call signal_ ("gate_err");
202 else do;
203 processid = a_processid;
204 ips_signal_name = a_ips_signal_name;
205 do ips_mask_index = 1 to sys_info$ips_mask_data.count
206 while (ips_signal_name ^= sys_info$ips_mask_data.mask (ips_mask_index).name);
207 end;
208 if ips_mask_index <= sys_info$ips_mask_data.count
209 then call pxss$ips_wakeup (processid, sys_info$ips_mask_data.mask (ips_mask_index).mask);
210 end;
211 return;
212 %page;
213
214
215
216
217
218
219
220
221 process_status:
222 entry (a_info_ptr);
223
224 processid = a_process_status.target_proc;
225 a_process_status.up_exec = 0;
226 a_process_status.up_mp = 0;
227 a_process_status.aptptr = null ();
228
229 process_mp_state = 1;
230
231 aptep = PROCESSID_TO_APTE (processid, "0"b);
232 if aptep ^= null ()
233 then do;
234 process_state = bin (apte.state, 17);
235 if apte.flags.loaded
236 then process_mp_state = process_mp_state + 2;
237 if apte.flags.eligible
238 then process_mp_state = process_mp_state + 1;
239
240 a_process_status.total_page_faults = apte.page_faults;
241 a_process_status.aptptr = aptep;
242 a_process_status.up_exec = process_state;
243 a_process_status.up_mp = process_mp_state;
244 a_process_status.up_block = apte.state_change_time;
245
246 a_process_status.up_cpu = apte.time_used_clock;
247 a_process_status.up_page = apte.paging_measure;
248 a_process_status.virtual_cpu = apte.virtual_cpu_time;
249 a_process_status.extra2 = 0;
250 end;
251
252 return;
253 %page;
254
255
256
257
258
259
260
261
262
263 set_cpu_monitor:
264 entry (a_processid, a_delta_vcpu, a_code);
265
266 processid = a_processid;
267 delta_vcpu = a_delta_vcpu;
268
269 call WIRE_MASK;
270
271
272
273 call pxss$lock_apte (processid, aptep, code);
274 if code = 0
275 then do;
276 if delta_vcpu < 0
277 then apte.cpu_monitor = 0;
278 else apte.cpu_monitor = divide (apte.virtual_cpu_time + delta_vcpu, 1024, 35);
279 call pxss$unlock_apte (aptep);
280 end;
281
282 call UNWIRE_UNMASK;
283
284
285
286 if code ^= 0
287 then a_code = error_table_$process_unknown;
288 else a_code = 0;
289
290 return;
291 %page;
292
293
294
295
296
297 set_timax:
298 entry (a_processid, a_timax);
299
300 processid = a_processid;
301 process_timax = a_timax;
302 if process_timax <= 0
303 then process_timax = tc_data$timax;
304
305 call WIRE_MASK;
306
307
308
309 call pxss$lock_apte (processid, aptep, code);
310 if code = 0
311 then do;
312 apte.timax = process_timax;
313 call pxss$unlock_apte (aptep);
314 end;
315
316 call UNWIRE_UNMASK;
317
318
319
320 return;
321 %page;
322
323
324
325
326
327
328
329
330 validate_processid:
331 entry (a_processid, a_code);
332
333 a_code = 0;
334
335 aptep = PROCESSID_TO_APTE ((a_processid), "0"b);
336 if aptep = null ()
337 then a_code = error_table_$process_unknown;
338
339 return;
340 %page;
341
342
343
344
345
346
347
348
349
350 suspend_tc:
351 entry ();
352
353 call lock$lock_fast (addr (tc_data$tc_suspend_lock));
354
355
356
357 call pxss$suspend_getwork ();
358
359
360 return;
361
362 %page;
363
364
365 resume_tc:
366 entry ();
367
368 call lock$unlock_fast (addr (tc_data$tc_suspend_lock));
369
370
371
372 return;
373 %page;
374 get_ipc_operands:
375 entry (P_ipc_r_offset, P_ipc_r_factor);
376
377
378
379
380
381
382
383 aptep = pds$apt_ptr;
384 P_ipc_r_offset = apte.ipc_r_offset;
385 P_ipc_r_factor = apte.ipc_r_factor;
386 return;
387 %page;
388 get_ipc_operands_priv:
389 entry (a_processid, P_ipc_r_offset, P_ipc_r_factor, a_code);
390
391
392
393
394
395
396 processid = a_processid;
397
398 call WIRE_MASK ();
399
400
401
402 call pxss$lock_apte (processid, aptep, code);
403 if code = 0
404 then do;
405 ipc_r_offset = apte.ipc_r_offset;
406 ipc_r_factor = apte.ipc_r_factor;
407 call pxss$unlock_apte (aptep);
408 end;
409 call UNWIRE_UNMASK ();
410
411
412
413 if code ^= 0
414 then a_code = error_table_$process_unknown;
415 else do;
416 P_ipc_r_offset = ipc_r_offset;
417 P_ipc_r_factor = ipc_r_factor;
418 a_code = 0;
419 end;
420 return;
421 %page;
422
423
424
425
426 PROCESSID_TO_APTE:
427 proc (processid, allow_special_procs) returns (ptr);
428
429 dcl processid bit (36) aligned;
430 dcl allow_special_procs bit (1) aligned;
431
432
433 dcl apte_offset fixed bin (18);
434 dcl first_apte_offset fixed bin (18);
435 dcl 1 pid aligned,
436 2 offset bit (18) unaligned,
437 2 unique bit (18) unaligned;
438 dcl taptep ptr;
439 dcl 1 tapte aligned like apte based (taptep);
440
441
442 unspec (pid) = processid;
443 apte_offset = bin (pid.offset, 18);
444 taptep = ptr (addr (tc_data$), pid.offset);
445 first_apte_offset = bin (rel (addr (tc_data$apt)), 18);
446
447 if apte_offset < first_apte_offset
448 then return (null ());
449 else if apte_offset >= first_apte_offset + tc_data$apt_size * size (apte)
450 then return (null ());
451 else if mod ((apte_offset - first_apte_offset), size (apte)) ^= 0
452 then return (null ());
453 else if tapte.processid ^= processid
454 then return (null ());
455 else if (^allow_special_procs & (tapte.flags.hproc | tapte.flags.idle))
456 then return (null ());
457 else return (taptep);
458
459 end PROCESSID_TO_APTE;
460 %page;
461
462
463
464 WIRE_MASK:
465 proc;
466
467 call wire_proc$wire_me;
468 call pmut$wire_and_mask (oldmask, ptwp);
469
470 end WIRE_MASK;
471
472
473
474
475
476
477
478
479
480
481
482 UNWIRE_UNMASK:
483 proc;
484
485 call pmut$unwire_unmask (oldmask, ptwp);
486 call wire_proc$unwire_me;
487
488
489 end UNWIRE_UNMASK;
490
491
492 %page; %include apte;
493 %page; %include process_status_return;
494 %page; %include ips_mask_data;
495 %page; %include arg_list;
496
497
498 end tc_util;