aboutsummaryrefslogtreecommitdiff
path: root/acid/alef
blob: 323a0ffa42aee6f655b0f1b5b74abcc4fa063adc (plain)
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
// runtime library definitions
if objtype=="mips2" then objtype="mips";

include("/sys/src/alef/lib/"+objtype+"/acid");

defn
pchan(addr)
{
	local l, n;

	complex Chan addr;

	if addr.sva then
		print("Sender waiting: buffer ", addr.sva, "\n");
	else
		print("No sender\n");

	if addr.rva then
		print("Receiver waiting: buffer ", addr.rva, "\n");
	else
		print("No receiver\n");

	if addr.async then {
		n = 0;
		l = addr.qh;
		while l do {
			n = n+1;
			l = l.next;
		}
		print("Async channel\n\t", n\D, " messsages queued\n\t");
		l = addr.free;
		while l do {
			n = n+1;
			l = l.next;
		}
		print(n\D, " free buffers\n");
	}
		
	if addr.selt then {
		l = "send";
		if addr.selt then
			l = "receive";
		print("In select ", l, ": task ", addr.selt\X, "\n");
		labstk(addr.selt);
	}
}

defn
tdb()
{
	local ta, tq;

	// Private proc tdb pointer
	ta = *{	0x7fffe000,
		0x0ffdf000,
		0xbfff5000 }[match(objtype, {"mips", "sparc", "386"})];

	complex Tdb ta;

	print("tdb ", ta.ntask, " tasks:");
 	if *ta then
		print("locked\n");
	else
		print("unlocked\n");

	if ta.ctask then {
		print("current task ", ta.ctask, "\n");
		Task(ta.ctask);
	}
	else
		print("proc is idle\n");

	tq = (Task)ta.runhd;
	if tq == 0 then
		return {};

	print("Tasks ready to run:\n");
	while tq != 0 do {
		print("Task(", tq, ")\n");
		tq = tq.link;		
	}
}

defn
lselect(addr)
{
	local c;

	complex Task addr;
	complex Chan c;

	c = addr.slist;
	if c == 0 then {
		print("No select pending\n");
		return {};
	}
	while c do {
		print("pchan(", c\X, ")\n");
		c = c.sellink;
	}
}

defn
pqlock(addr)
{
	local t;

	complex QLock addr;

	if *addr then
		print("QLock is under modification\n");
	if addr.used == 0 then
		return {};

	print("QLock is held\n");
	t = addr.queue;
	complex Task t;
	if t == 0 then {
		print("No tasks waiting\n");
		return {};
	}
	print("Tasks waiting:\n");
	while t do {
		print("Task(", t, ")\n");
		tq = tq.qlink;		
	}
}

srcpath = {
	"./",
	"/sys/src/alef/lib/port/",
	"/sys/src/alef/lib/p9/",
	"/sys/src/alef/lib/"+objtype+"/"
};

defn labstk(l)
{
	if objtype == "386" then
		_stk(ALEF_switch, *l, linkreg(0), 0);
	else
		_stk(*(l+4), *l, linkreg(0), 0);
}

print(acidfile);

include("/sys/src/alef/lib/port/acid."+objtype);
include("/sys/src/alef/lib/p9/acid."+objtype);