use stdio.h "coro.h" struct count Thread t Int *o count(struct count *t) switch t->t.pc 0 get(t->o, t) ; t->t.pc=1 ; return 1 t->o->i=0 while t->o->i<11 yield(t->o, t.t) ; t->t.pc=2 ; return 2 ++t->o->i struct add Thread t Int *i1, *i2, *o add(struct add *t) switch t->t.pc 0 while 1 yield(t->o, t) ; yield(t->i1, t) ; yield(t->i2, t) t->pc=1 ; return 1 t->pc=2 ; return 2 t->pc=3 ; return 3 t->o->i = t->i1->i + t->i2->i struct printd Thread Int *i printd(struct printd *t) switch t->pc 0 while 1 yield(t->i, t) ; t->pc=1 ; return 1 printf("%d\n", t->i->i) main() Int i1, i2, i3 struct count c1, c2 struct add a struct printd p c1.f = count c2.f = count a.f = add p.f = printd connect(&c1.o, &i1, &a.i1) connect(&c2.o, &i2, &a.i2) connect(&a.o, &i3, &p.i) start(&c1) start(&c2) start(&a) start(&p) run()