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;i<chunk->max;i++) {
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;
}
done = xbt_queue_new(-1,sizeof(work_chunk_t));
- INFO0("Prepare some work");
+ XBT_INFO("Prepare some work");
for (i=0;i<maxint/perchunk;i++) {
chunk = xbt_new0(s_work_chunk_t,1);
chunk->min = i*perchunk;
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;i<maxint/perchunk;i++) {
work_chunk_t chunk;
xbt_strbuff_t buff = xbt_strbuff_new();
xbt_strbuff_append(buff,",");
xbt_strbuff_append(buff,number);
}
- INFO3("Primes in [%d,%d]: %s",chunk->min,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);