X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f7669511dbd0ea516d79d4e56f638e5cabfbac27..c215f8139368ac8b172ad664c05d4f2b4211a961:/examples/gras/spawn/spawn.c diff --git a/examples/gras/spawn/spawn.c b/examples/gras/spawn/spawn.c index 4b3489cf96..f2d74b1831 100644 --- a/examples/gras/spawn/spawn.c +++ b/examples/gras/spawn/spawn.c @@ -33,7 +33,8 @@ int worker(int argc, char *argv[]) { xbt_ex_t e; TRY { xbt_queue_shift_timed(todo,&chunk,0); - } CATCH(e) { + } + CATCH(e) { if (e.category != timeout_error) { RETHROW; } @@ -42,7 +43,7 @@ int worker(int argc, char *argv[]) { if (!moretodo) break; // Do not break from within the CATCH, exceptions don't like it. - INFO2("Got [%d;%d] to do",chunk->min,chunk->max); + XBT_INFO("Got [%d;%d] to do",chunk->min,chunk->max); GRAS_BENCH_ALWAYS_BEGIN(); int i; for (i=chunk->min;imax;i++) { @@ -57,7 +58,7 @@ int worker(int argc, char *argv[]) { GRAS_BENCH_ALWAYS_END(); xbt_queue_push(done,&chunk); } - INFO0("No more work for me; bailing out"); + XBT_INFO("No more work for me; bailing out"); return 0; } @@ -81,7 +82,7 @@ int server(int argc, char *argv[]) done = xbt_queue_new(-1,sizeof(work_chunk_t)); - INFO0("Prepare some work"); + XBT_INFO("Prepare some work"); for (i=0;imin = i*perchunk; @@ -90,15 +91,17 @@ int server(int argc, char *argv[]) xbt_queue_push(todo,&chunk); } - INFO0("Spawn the kids"); + XBT_INFO("Spawn the kids"); for (i = 0; i < child_amount; i++) { - worker_args = xbt_new0(char *, 1); + char *name = bprintf("child%d",i); + worker_args = xbt_new0(char *, 2); worker_args[0] = xbt_strdup("child"); worker_args[1] = NULL; - gras_agent_spawn(bprintf("child%d",i), NULL, worker, 1, worker_args, NULL); + gras_agent_spawn(name, worker, 1, worker_args, NULL); + free(name); } - INFO0("Fetch their answers"); + XBT_INFO("Fetch their answers"); for (i=0;imin,chunk->max,buff->data); + XBT_INFO("Primes in [%d,%d]: %s",chunk->min,chunk->max,buff->data); xbt_strbuff_free(buff); } + gras_os_sleep(.1);/* Let the childs detect that there is nothing more to do */ xbt_queue_free(&todo); xbt_queue_free(&done);