/******************************************************************/ /* From: Kuang-chun Tao */ /* Document for the programming Techniques with processes for */ /* Asynchronous remote procedure calls. */ /* This is a example how asynchronous remote procedure calls work.*/ /* Asynchronous calls do not wait for the remote part to terminate*/ /* before returning. Asynchronous calls can create parallelism, */ /* but they are more defficult to use since the caller can not */ /* assume the operation is finished. Procedure storeAt is */ /* asynchronous. Actually, there are two varieties of asynchronous*/ /* calls: calls that return no result, like atoreAt. One is calls */ /* that return a result that arrives back at some later time. */ /******************************************************************/ #include "amdc96.h" #include #define tag 1 Location my_loc; LocName my_name; void doStore(Message m, Location loc) { Message p; amdc_putLoc(loc, m); while((p = amdc_getLoc(loc, tag)) != NULL) printf("I am node %d, got a message\n", amdc_getMyId()); } void storeAt(Message m, LocName L) { amdc_sendToAsDo(m, L, tag, (Script)doStore); } int Main() { LocName L; int *m1; while (1) { L = amdc_0DLocName(AMDC_SYMB_HASH); m1 = amdc_rawMsg(sizeof(int)); *m1 = amdc_getMyId(); storeAt((Message)m1, L); printf("I am node %d, sent out a message\n", amdc_getMyId()); } }