Mercurial > hg > Members > nobuyasu > CbC
view ABP/scheduler.c @ 33:3946f8d26710 draft default tip
add benchmarck/binary-trees
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 09 Apr 2013 16:41:30 +0900 |
parents | 18d2a590bc10 |
children |
line wrap: on
line source
#define __environment _CbC_environment #define __return _CbC_return int comm_bit_s; /* communication bit for sender */ int comm_bit_r; /* communication bit for receiver */ char *comm_msg; /* communication message */ code (*ret)(int,void*); void *env; struct packet { int bit; /* alternating bit */ char **msg; /* messages */ code (*next)(); /* next code segment */ }; struct packet spkt; /* sender packet */ struct packet rpkt; /* receiver packet */ /* sender.c */ extern code s_sendState(struct packet, int); extern code s_receiveState(struct packet, int); /* receiver.c */ extern code r_receiveState(struct packet, int); extern code r_sendState(struct packet, int); char *msgs[8] = { "hoge1", "hoge2", "hoge3", "hoge4", "hoge5", 0 }; /* Round-Robin */ code schedule(struct packet pkt, int i) { if (pkt.next == s_sendState || pkt.next == s_receiveState) { spkt = pkt; if (msgs[i] == 0) goto ret(0, env); goto rpkt.next(rpkt, i); } if (pkt.next == r_sendState || pkt.next == r_receiveState) { rpkt = pkt; goto spkt.next(spkt, i); } goto ret(0, env); } int main(void) { /* initialize */ comm_bit_s = -1; comm_bit_r = -1; spkt.bit = 0; rpkt.bit = 1; spkt.msg = msgs; rpkt.msg = msgs; spkt.next = s_sendState; rpkt.next = r_receiveState; ret = _CbC_return; env = _CbC_environment; goto s_sendState(spkt, 0); // goto r_receiveState(rpkt, 0); }