alef 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // runtime library definitions
  2. if objtype=="mips2" then objtype="mips";
  3. include("/sys/src/alef/lib/"+objtype+"/acid");
  4. defn
  5. pchan(addr)
  6. {
  7. local l, n;
  8. complex Chan addr;
  9. if addr.sva then
  10. print("Sender waiting: buffer ", addr.sva, "\n");
  11. else
  12. print("No sender\n");
  13. if addr.rva then
  14. print("Receiver waiting: buffer ", addr.rva, "\n");
  15. else
  16. print("No receiver\n");
  17. if addr.async then {
  18. n = 0;
  19. l = addr.qh;
  20. while l do {
  21. n = n+1;
  22. l = l.next;
  23. }
  24. print("Async channel\n\t", n\D, " messsages queued\n\t");
  25. l = addr.free;
  26. while l do {
  27. n = n+1;
  28. l = l.next;
  29. }
  30. print(n\D, " free buffers\n");
  31. }
  32. if addr.selt then {
  33. l = "send";
  34. if addr.selt then
  35. l = "receive";
  36. print("In select ", l, ": task ", addr.selt\X, "\n");
  37. labstk(addr.selt);
  38. }
  39. }
  40. defn
  41. tdb()
  42. {
  43. local ta, tq;
  44. // Private proc tdb pointer
  45. ta = *{ 0x7fffe000,
  46. 0x0ffdf000,
  47. 0xbfff5000 }[match(objtype, {"mips", "sparc", "386"})];
  48. complex Tdb ta;
  49. print("tdb ", ta.ntask, " tasks:");
  50. if *ta then
  51. print("locked\n");
  52. else
  53. print("unlocked\n");
  54. if ta.ctask then {
  55. print("current task ", ta.ctask, "\n");
  56. Task(ta.ctask);
  57. }
  58. else
  59. print("proc is idle\n");
  60. tq = (Task)ta.runhd;
  61. if tq == 0 then
  62. return {};
  63. print("Tasks ready to run:\n");
  64. while tq != 0 do {
  65. print("Task(", tq, ")\n");
  66. tq = tq.link;
  67. }
  68. }
  69. defn
  70. lselect(addr)
  71. {
  72. local c;
  73. complex Task addr;
  74. complex Chan c;
  75. c = addr.slist;
  76. if c == 0 then {
  77. print("No select pending\n");
  78. return {};
  79. }
  80. while c do {
  81. print("pchan(", c\X, ")\n");
  82. c = c.sellink;
  83. }
  84. }
  85. defn
  86. pqlock(addr)
  87. {
  88. local t;
  89. complex QLock addr;
  90. if *addr then
  91. print("QLock is under modification\n");
  92. if addr.used == 0 then
  93. return {};
  94. print("QLock is held\n");
  95. t = addr.queue;
  96. complex Task t;
  97. if t == 0 then {
  98. print("No tasks waiting\n");
  99. return {};
  100. }
  101. print("Tasks waiting:\n");
  102. while t do {
  103. print("Task(", t, ")\n");
  104. tq = tq.qlink;
  105. }
  106. }
  107. srcpath = {
  108. "./",
  109. "/sys/src/alef/lib/port/",
  110. "/sys/src/alef/lib/p9/",
  111. "/sys/src/alef/lib/"+objtype+"/"
  112. };
  113. defn labstk(l)
  114. {
  115. if objtype == "386" then
  116. _stk(ALEF_switch, *l, linkreg(0), 0);
  117. else
  118. _stk(*(l+4), *l, linkreg(0), 0);
  119. }
  120. print("/sys/lib/acid/alef");
  121. include("/sys/src/alef/lib/port/acid."+objtype);
  122. include("/sys/src/alef/lib/p9/acid."+objtype);