Blob
1 // runtime library definitions2 if objtype=="mips2" then objtype="mips";4 include("/sys/src/alef/lib/"+objtype+"/acid");6 defn7 pchan(addr)8 {9 local l, n;11 complex Chan addr;13 if addr.sva then14 print("Sender waiting: buffer ", addr.sva, "\n");15 else16 print("No sender\n");18 if addr.rva then19 print("Receiver waiting: buffer ", addr.rva, "\n");20 else21 print("No receiver\n");23 if addr.async then {24 n = 0;25 l = addr.qh;26 while l do {27 n = n+1;28 l = l.next;29 }30 print("Async channel\n\t", n\D, " messsages queued\n\t");31 l = addr.free;32 while l do {33 n = n+1;34 l = l.next;35 }36 print(n\D, " free buffers\n");37 }39 if addr.selt then {40 l = "send";41 if addr.selt then42 l = "receive";43 print("In select ", l, ": task ", addr.selt\X, "\n");44 labstk(addr.selt);45 }46 }48 defn49 tdb()50 {51 local ta, tq;53 // Private proc tdb pointer54 ta = *{ 0x7fffe000,55 0x0ffdf000,56 0xbfff5000 }[match(objtype, {"mips", "sparc", "386"})];58 complex Tdb ta;60 print("tdb ", ta.ntask, " tasks:");61 if *ta then62 print("locked\n");63 else64 print("unlocked\n");66 if ta.ctask then {67 print("current task ", ta.ctask, "\n");68 Task(ta.ctask);69 }70 else71 print("proc is idle\n");73 tq = (Task)ta.runhd;74 if tq == 0 then75 return {};77 print("Tasks ready to run:\n");78 while tq != 0 do {79 print("Task(", tq, ")\n");80 tq = tq.link;81 }82 }84 defn85 lselect(addr)86 {87 local c;89 complex Task addr;90 complex Chan c;92 c = addr.slist;93 if c == 0 then {94 print("No select pending\n");95 return {};96 }97 while c do {98 print("pchan(", c\X, ")\n");99 c = c.sellink;100 }101 }103 defn104 pqlock(addr)105 {106 local t;108 complex QLock addr;110 if *addr then111 print("QLock is under modification\n");112 if addr.used == 0 then113 return {};115 print("QLock is held\n");116 t = addr.queue;117 complex Task t;118 if t == 0 then {119 print("No tasks waiting\n");120 return {};121 }122 print("Tasks waiting:\n");123 while t do {124 print("Task(", t, ")\n");125 tq = tq.qlink;126 }127 }129 srcpath = {130 "./",131 "/sys/src/alef/lib/port/",132 "/sys/src/alef/lib/p9/",133 "/sys/src/alef/lib/"+objtype+"/"134 };136 defn labstk(l)137 {138 if objtype == "386" then139 _stk(ALEF_switch, *l, linkreg(0), 0);140 else141 _stk(*(l+4), *l, linkreg(0), 0);142 }144 print(acidfile);146 include("/sys/src/alef/lib/port/acid."+objtype);147 include("/sys/src/alef/lib/p9/acid."+objtype);