/* testctx.c
L. Stewart October 6, 1982 3:03 PM
*/
extern GetAll();
extern InitQueue();
extern Enqueue();
extern Alloc();
extern settmr();
extern tmrexp();
extern Block();
extern InitNContext();
extern CallContext();
extern int pr1, pr2, pr3;
int zone;
int q[2];
int space, ctx;
main()
{
int i, mt;
zone = GetAll();
InitQueue(q);
initpa();
space = Alloc(zone, 300);
wf("a1\r");
ctx = InitNContext("pr1", space, 300, pr1);
wf("i1\r");
Enqueue(q, ctx);
wf("e1\r");
space = Alloc(zone, 300);
wf("a2\r");
ctx = InitNContext("pr2", space, 300, pr2);
wf("i2\r");
Enqueue(q, ctx);
wf("e2\r");
space = Alloc(zone, 300);
wf("a3\r");
ctx = InitNContext("pr3", space, 300, pr3);
wf("i3\r");
Enqueue(q, ctx);
wf("e3\r");
for (i=0; i<10; i+=1) {
settmr(2000, &mt);
while(!tmrexp(&mt));
wf1("loop %d\r", i);
};
for (;;) {
CallContext(q[0]);
wf("c");
};
};
proc1()
{
wf("p1\r");
for (;;) {
Dismiss(1000);
putchar('1');
};
};
proc2()
{
wf("p2\r");
for (;;) {
Dismiss(2000);
putchar('2');
};
};
proc3()
{
wf("p3\r");
for (;;) {
Dismiss(3000);
putchar('3');
};
};
Dismiss(t)
int t;
{
int tmr;
settmr(t, &tmr);
while(!tmrexp(&tmr)) Block();
};