Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!ncrlnk!ncrcae!hubcap!wen-king From: wen-king@csvax.caltech.edu (Wen-King Su) Newsgroups: comp.parallel Subject: Re: using network machines as compute servers Message-ID: <7300@hubcap.clemson.edu> Date: 4 Dec 89 14:08:01 GMT Sender: fpst@hubcap.clemson.edu Lines: 90 Approved: parallel@hubcap.clemson.edu >From: larsa@nada.kth.se (Lars Andersson) I recommend Cosmic Environment because: 1) Cosmic Environment runs without modification on all implementations of BSD, System V, and Xenix OS with socket support. 2) CE's message model is simple and intuitive -- just like malloc and free. 3) CE message primitives are general and satisfies most programming needs. 4) CE message primitives can be simply and efficiently emulated in almost all multicomputer programming systems. Therefore, porting CE programs to other systems is quite simple. This is a way to protect your investiment in your programs. picked up by the "slaves" as each completes its current task. When a slave picked up and stored by the master (depending on the problem, one might want body)" when it gets the 'ADD' message it asked for. ---------------------------------------------------------------------------- #include typedef struct MHEAD MHEAD; struct MHEAD { MHEAD *next; /* for making a queue */ short type; /* type of the message */ short node, pid; /* reference of the sender process */ short count; /* number of bytes in message body */ char body[1]; }; /* actually 'count' bytes long */ MHEAD *task_head, *task_tail; /* queues of tasks to be work on */ MHEAD *wait_head, *wait_tail; /* queues of processes waiting for work */ #define ADD 1 #define GET 2 main() { MHEAD *mp, *tp, *wp; while(mp = (MHEAD *) xrecvb()) /* repeatedly get a message */ { if(mp->type == ADD) /* message to add a task. */ { if(!wait_head) /* task not waited for -> queue it */ { if(task_head) task_tail = task_tail->next = tp; else task_tail = task_head = tp; tp->next = 0; } else /* waited for -> dispatch task */ { wp = wait_head; wait_head = wp->next; xsend(mp,wp->node,wp->pid); xfree(wp); } } else if(mp->type == GET) /* message to get a task */ { if(!task_head) /* no task available -> queue it */ { if(wait_head) wait_tail = wait_tail->next = wp; else wait_tail = wait_head = wp; wp->next = 0; } else /* available -> dispatch task */ { tp = task_head; task_head = tp->next; xsend(tp,mp->node,mp->pid); xfree(mp); } } } } ---------------------------------------------------------------------------- Brought to you by Super Global Mega Corp .com