X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/d47d44b2ed067c834ef210ad544512e7581a1c8e..147d0e88c4da14c801d15e0875bedb474180bea2:/process.cpp?ds=inline diff --git a/process.cpp b/process.cpp index 7605818..d1576ce 100644 --- a/process.cpp +++ b/process.cpp @@ -40,7 +40,13 @@ process::process(int argc, char *argv[]) int process::run() { INFO0("Coucou !"); - MSG_process_sleep(100.0); // xxx + + int n = 100; + while (n--) { + compute(); + receive(); + } + // MSG_process_sleep(100.0); // xxx /* xxx: * while (there is something to do) { * compute some task; @@ -61,10 +67,25 @@ int process::run() return 0; } +void process::receive() +{ + m_task_t task; + while ((task = comm.recv())) { + message *msg = (message *)MSG_task_get_data(task); + DEBUG3("Received load: %g, info: %g from %s", + msg->transfer, msg->measure, + MSG_host_get_name(MSG_task_get_source(task))); + load += msg->transfer; + // fixme: what is xxx ??? + // neigh[xxx].setLoad(msg->measure); + } +} + void process::compute() { double duration = opt::comp_cost(load); m_task_t task = MSG_task_create("computation", duration, 0.0, NULL); + DEBUG2("Compute %g flop%s.", duration, duration > 1 ? "s" : ""); MSG_task_execute(task); MSG_task_destroy(task); }