Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde!uunet!ncrlnk!ncrcae!hubcap!carriero-nicholas From: carriero-nicholas@YALE.EDU (Nicholas Carriero) Newsgroups: comp.parallel Subject: Re: using network machines as compute servers Message-ID: <7325@hubcap.clemson.edu> Date: 5 Dec 89 13:44:46 GMT Sender: fpst@hubcap.clemson.edu Lines: 71 Approved: parallel@hubcap.clemson.edu In article <7300@hubcap.clemson.edu> wen-king@csvax.caltech.edu (Wen-King Su) writes: >>From: larsa@nada.kth.se (Lars Andersson) >>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 > >This can't be that difficult. You write a batch process (listed below). >The master put tasks into the batch by sending 'ADD' messages to the batch >process. The slave process gets a task by sending a 'GET' message to the >batch process and waiting for a 'ADD' message in reply. You can use another >batch process to collect the results, or add more message types to this >batch program to handle collection of results. > >The 'body' of 'ADD' messages contains task specification. In the simplest >case, it can be a string to be passed to shell. And the slave process >simply do a "system(message->body)" when it gets the 'ADD' message it asked for. > [54 Lines of code to implement a batch process deleted.] > You're right, it's not that difficult. Why should the user have to think about (let alone design and implement) a 'batch' process she doesn't need? Attached is a skeletal solution in C-Linda for the master and the worker (i.e. the control structure for the whole problem), but this isn't a Linda ad (really!)---solutions with a similar structure could be given in any number of systems. -Nick Carriero #include "prog_defs.h" master() { int i; struct result r; struct task t; int tasks; /* Create workers. */ for (i = 0; i < NW; ++i) eval("worker", worker()); /* Generate tasks. */ for (tasks = 0; new_task(&t); ++tasks) out("task", t); /* Consume results. */ for (; tasks; --tasks) { in("result", ? r); update(&r); } /* Kill workers. */ t.type = DIE; for (i = 0; i < NW; ++i) out("task", t); } worker() { struct result r; struct task t; while (1) { in("task", ? t); if (t.type == DIE) return; compute(&t, &r); out("result", r); } }