1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
PACKET system info DEFINES (* Autor: J.Liedtke *)
(* Stand: 10.09.84 *)
task info ,
task status ,
storage info ,
help :
LET supervisor mode = 0 ,
simple mode = 1 ,
status mode = 2 ,
storage mode = 3 ,
ack = 0 ,
channel field = 4 ,
prio field = 6 ,
cr lf = ""13""10"" ,
cr = ""13"" ,
page = ""1""4"" ,
begin mark= ""15"" ,
end mark = ""14"" ,
bell = ""7"" ,
esc = ""27"" ;
TEXT VAR task name , record ;
DATASPACE VAR ds := nilspace ;
PROC task info :
task info (simple mode)
ENDPROC task info ;
PROC task info (INT CONST mode) :
open list file ;
task info (mode, list file) ;
show task info .
open list file :
forget (ds) ;
ds := nilspace ;
FILE VAR list file := sequential file (output, ds) .
show task info :
IF mode <> supervisor mode
THEN show (list file)
ELSE open editor (list file, FALSE) ;
edit (groesster editor, "q", PROC (TEXT CONST) no orders)
FI .
ENDPROC task info ;
PROC task info (INT CONST mode, FILE VAR list file) :
access catalogue ;
IF mode > simple mode
THEN generate head
FI ;
list tree (list file, supervisor,0, mode) .
generate head :
put (list file, date) ;
put (list file, " ") ;
put (list file, time of day) ;
put (list file, " ") ;
IF mode = storage mode
THEN put (list file, "K ")
FI ;
put (list file, " CPU PRIO CHAN STATUS") ;
line (list file) .
ENDPROC task info ;
PROC task info (INT CONST level, fremdstation):
IF fremdstation = station (myself)
THEN task info (level)
ELSE
disable stop;
DATASPACE VAR x:= nilspace;
BOUND INT VAR l := x; l := level;
call (collector, 256+fremdstation, x, rtn);
INT VAR rtn;
IF rtn = ack
THEN FILE VAR ti:= sequential file (modify, x) ;
show (ti)
ELSE forget (x) ;
errorstop ("Station " + text (fremdstation) + " antwortet nicht")
FI ;
forget (x)
FI
END PROC task info;
PROC no orders (TEXT CONST ed kommando taste) :
IF ed kommando taste = "q"
THEN quit
ELSE out (""7"")
FI
ENDPROC no orders ;
PROC list tree (FILE VAR list file,
TASK CONST first son, INT CONST depth, mode) :
enable stop ;
TASK VAR actual task := first son ;
WHILE NOT is niltask (actual task) REP
list actual task ;
list tree (list file, son (actual task), depth+1, mode) ;
actual task := brother (actual task)
PER .
list actual task :
record := "" ;
generate layout and task name ;
IF mode > simple mode
THEN tab to info position ;
show storage if wanted ;
record CAT cpu time of (actual task) ;
record CAT prio of actual task ;
record CAT channel of actual task ;
record CAT " " ;
record CAT status of (actual task)
FI ;
putline (list file, record) .
generate layout and task name :
INT VAR i ;
FOR i FROM 1 UPTO depth REP
record CAT " "
PER ;
task name := name (actual task) ;
record CAT task name .
tab to info position :
record := subtext (record, 1, 40) ;
FOR i FROM LENGTH record + 1 UPTO 40 REP
record CAT "."
PER ;
record CAT " " .
show storage if wanted :
IF mode = storage mode
THEN record CAT text (storage (actual task), 5) ;
record CAT " "
FI .
prio of actual task :
text (pcb (actual task, prio field),4) .
channel of actual task :
INT CONST channel := pcb (actual task, channel field) ;
IF channel = 0
THEN " -"
ELSE text (channel,4)
FI .
ENDPROC list tree ;
TEXT PROC cpu time of (TASK CONST actual task) :
disable stop ;
TEXT VAR result := subtext (time (clock (actual task), 12), 1, 10) ;
IF is error
THEN clear error ;
result := 10 * "*"
FI ;
result
ENDPROC cpu time of ;
TEXT PROC status of (TASK CONST actual task) :
SELECT status (actual task) OF
CASE 0 : "-busy-"
CASE 1 : "i/o"
CASE 2 : "wait"
CASE 4 : "busy-blocked"
CASE 5 : "i/o -blocked"
CASE 6 : "wait-blocked"
OTHERWISE "--dead--"
END SELECT .
ENDPROC status of ;
PROC task status :
task status (myself)
ENDPROC task status ;
PROC task status (TEXT CONST task name) :
task status (task (task name))
ENDPROC task status ;
PROC task status (TASK CONST actual task) :
IF exists (actual task)
THEN put status of task
ELSE errorstop ("Task nicht vorhanden")
FI .
put status of task :
line ;
put (date); put (time of day) ;
put (" TASK:") ;
put (name (actual task)) ;
line (2) ;
put ("Speicher:"); put (storage (actual task)); putline ("K");
put ("CPU-Zeit:"); put (cpu time of (actual task)) ; line;
put ("Zustand :"); write (status of (actual task));
put (", (prio");
write (text (pcb (actual task, prio field)));
put ("), Kanal") ;
IF channel (actual task) = 0
THEN put ("-")
ELSE put (channel (actual task))
FI ;
line .
ENDPROC task status ;
PROC storage info :
INT VAR size, used ;
storage (size, used) ;
out (""13""10" ") ;
put (used) ;
put ("K von") ;
put (size plus reserve) ;
putline ("K sind belegt!") .
size plus reserve :
int (real (size + 24) * 64.0 / 63.0 ) .
ENDPROC storage info ;
PROC help :
IF NOT exists ("help")
THEN get help file
FI ;
FILE VAR f := sequential file (modify, "help") ;
help (f) .
get help file :
TEXT VAR old std param := std ;
IF exists ("help", father)
THEN fetch ("help")
ELSE fetch ("help", public)
FI ;
last param (old std param) .
ENDPROC help ;
PROC help (FILE VAR help file) :
initialize help command ;
REP
out (page) ;
to paragraph ;
show paragraph ;
get show command
UNTIL is quit command PER .
initialize help command :
TEXT VAR
help command := getcharety ;
IF help command = ""
THEN help command := "0"
FI .
to paragraph :
col (help file, 1) ;
to line (help file, 1) ;
downety (help file, "#" + help command + "#") ;
IF eof (help file)
THEN to line (help file, 1) ;
out (bell)
FI .
show paragraph :
show headline ;
WHILE NOT end of help subfile REP
show help line
PER ;
show bottom line .
show headline :
out (begin mark) ;
INT CONST dots := (x size - len (help file) - 5) DIV 2 ;
dots TIMESOUT "." ;
exec (PROC show line, help file, 4) ;
dots TIMESOUT "." ;
out (end mark) ;
down (help file) .
show help line :
out (cr lf) ;
exec (PROC show line, help file, 1) ;
down (help file) .
show bottom line :
cursor (5, y size) ;
exec (PROC show line, help file, 3) ;
out (cr) .
get show command :
TEXT VAR char ;
get char (char) ;
IF char = esc
THEN get char (char)
FI ;
IF char >= " "
THEN help command := char
ELSE out (bell)
FI .
end of help subfile : pos (help file,"##",1) <> 0 OR eof (help file) .
is quit command : help command = "q" OR help command = "Q" .
ENDPROC help ;
PROC show line (TEXT CONST line, INT CONST from) :
outsubtext (line, from, x size - from)
ENDPROC show line ;
ENDPACKET system info ;
|