!************************* !* Batchs/Batch * !* DATE: 05.jan.82 * !* loads a series of * !* tasks, from input(1) * !************************* %include "b_deimosspecs" %begin %constinteger load ser = 5 %recordformat pe(%byteinteger service, reply, (%integer a1, %c %byteintegername b, %integer c %or %c %byteinteger line, line type, %integer ad, %byteinteger rxint, txint)) %record (pe)p %owninteger task id = 26; ! private ser to distinguish calls %integer i, j, k, time, user id, load type %owninteger op on = 0 %owninteger hours, mins, n hours, n mins, secs %integer line, line type, address, rxint, txint, id %owninteger first prot = 0 %ownstring (255)s %integerfn call loader(%string(255)name s) %recordformat p3f(%byteinteger ser, reply, a1, a2, %c %byteintegername b, %byteinteger c1, c2) %record (p3f) p3 S = S.snl p3_ser = load ser; p3_reply = own id p3_a1 = 1; p3_a2 = fsys p3_b == byteinteger(addr(s)+1) %if load type = 0 %start p3_c1 = 4; p3_c2 = task id; ! tis task 'owns' the new task %else p3_c1 = 4; p3_c2 = tt no; ! don't report to me type %finish ponoff(p3) %result = p3_a1 %end %routine read string(%string(255)name s) !! terminates on either a nl or a semi colon %integer n length(s) = 0 %cycle n = nextsymbol %if n = nl %or n = ';' %or n = '*' %thenreturn s = s.tostring(n) skipsymbol %repeat %end %routine read time(%integername h, m) %integerfn get %integer i readsymbol(i) %unless '0' <= i <='9' %then %result = -1 %result = i-'0' %end %integer a, b, c, d %cycle a = get; -> failed %if a<0 b = get; -> failed %if b<0 readsymbol(d); -> failed %unless d = ' ' c = get; -> failed %if c < 0 d = get; -> failed %if d < 0 a = 10*a+b; c = 10*c+d -> failed %if a > 24 %or c > 60 h = a; m = c skipsymbol %return failed skipsymbol %while nextsymbol # nl skipsymbol prompt("Time as HH MM please:") %repeat %end %routine simulate tt(%integer ad, len) %integer i, j, k, x, len2, xad, seg, ttreply, sym %on %event 9 %start; ! eof in file printstring("Batch: Unexpected Eof! ") p_service = tt reply; p_reply = task id p_a1 = 0; ! failed pon(p) i = map virt(0, -1, 0) %return %finish !! p_a1 = 0 read, p_a1 = 1 write tt reply = p_reply %if p_a1 = 0 %start seg = ad >> 13 i = map virt(tt reply, seg, 0) %if i = 0 %start failed: printstring("Batch: Failed to map segment of ") printstring(s); %stop %finish xad = k'000000'!(ad&k'17777'); ! address in seg 0 len2 = 0 %cycle len2 = len2+1 readsymbol(sym) printsymbol(sym) %if op on = 0 byteinteger(xad) = sym %exit %if sym = nl xad = xad+1 %repeat p_service = tt reply; p_reply = task id p_a1 = len2 pon(p) i = map virt(0, -1, 0) %return %finish seg = ad >> 13 i = map virt(tt reply, seg, 0) -> failed %if i = 0 xad = k'000000'!(ad&k'17777') %cycle i = 0, 1, len-1 x = byteinteger(xad) printsymbol(x) %if op on = 0 xad = xad+1 %repeat i = map virt(0, -1, 0) p_service = tt reply; p_reply = task id p_a1 = 0 pon(p) %end linkin(task id) %on %event 9 %start printstring("Batch Unexpected Eof ") %stop %finish select input(1); select output(1) %cycle readsymbol(i); printsymbol(i) %exitif i = nl %repeat %cycle %if int # 0 %then %stop readstring(s) %if s = "END" %then %exit %if s -> ("OUTPUT ").s %start; ! output flag printstring("Command:Output "); printstring(s); newline skipsymbol %if s = "OFF" %then op on = 1 %else op on = 0 %continue %finish %if s -> ("LOGON ").s %start; ! logon command printstring("Command:logon "); printstring(s); newline skipsymbol i = charno(s, 1)-'0'; j = charno(s, 2)-'0' %if length(s) = 0 %or length(s) > 2 %or i<0 %or i>7 %start no: printstring("invalid logon number ") %continue %finish %if length(s) = 1 %then fsys = i %else %start -> no %if j<0 %or j>7 fsys = i<<3+j %finish %continue %finish %if s-> ("TIME").s %start select input(0); select output(0) prompt("Give current Time as HH MM:") read time(hours, mins) alarm(50) prompt("Give start Time as HH MM:") read time(nhours, n mins) secs = 1 %cycle p_service = 0; poff(p) secs = secs+1 %if secs = 60 %start secs = 0; mins = mins+1 %finish %if mins >= 60 %start mins=mins-60; hours = hours+1 %if hours = 24 %then hours = 0 %finish %if int = '?' %or (mins = 0 %and secs = 0) %start int = 0 printstring("time:"); write(hours, 0); write(mins, 0) newline %finish %if hours = n hours %and mins = n mins %then %exit alarm(50) %repeat select output(1); select input(1) %continue %finish load type = 0 %if nextsymbol = '*' %then load type = 1 %and skipsymbol user id = call loader(s) skipsymbol %if user id = 0 %start printstring("Failed to load:"); printstring(s) %continue %finish %if op on = 0 %start printstring("Command:"); printstring(s) %finish !! program is now executing, could be asked for !! 1. tt input, 2. tt output, or 3. task termination newline %and %continue %if load type # 0; ! dont wait for the specials %cycle p_service = 0; poff(p) %if p_service= task id %start simulate tt(p_ad, p_c) %else length(s) = length(s)-1; ! delete the end nl %if p_c # 0 %start; ! fauilure flag printstring(s); printstring(" F A U L T "); write(p_c, 1) newline %finish !! should be task terminated !! how about a flag???? %if op on = 0 %start printstring(s); printstring(" Stopped") %if hours # 0 %start printstring(" at"); write(hours, 1); write(mins, 1) newline %finish %finish %exit %finish %repeat %repeat printstring(" Batch terminates ") %endofprogram