X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/36b1436fb4b718fb785fb22762a772d9171d8609..8bc85164acb335cf909052b966b2ee4932e06cd7:/examples/c/cloud-masterworker/cloud-masterworker.c diff --git a/examples/c/cloud-masterworker/cloud-masterworker.c b/examples/c/cloud-masterworker/cloud-masterworker.c index 5afa0123ed..1e54f2d514 100644 --- a/examples/c/cloud-masterworker/cloud-masterworker.c +++ b/examples/c/cloud-masterworker/cloud-masterworker.c @@ -21,14 +21,14 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(cloud_masterworker, "Messages specific for this exa #define FINALIZE 221297 /* a magic number to tell people to stop working */ const double comp_size = 10000000; -const double comm_size = 10000000; +const long comm_size = 10000000; static void send_tasks(int nb_workers) { for (int i = 0; i < nb_workers; i++) { char mbox_name[MAXMBOXLEN]; snprintf(mbox_name, MAXMBOXLEN, "MBOX:WRK%02d", i); - double* payload = (double*)malloc(sizeof(double)); + double* payload = xbt_malloc(sizeof(double)); *payload = comp_size; sg_mailbox_t mbox = sg_mailbox_by_name(mbox_name); @@ -37,7 +37,7 @@ static void send_tasks(int nb_workers) } } -static void worker_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]) +static void worker_fun(int argc, char* argv[]) { const char* pr_name = sg_actor_self_get_name(); char mbox_name[MAXMBOXLEN]; @@ -63,13 +63,11 @@ static void worker_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[ } } -static void master_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]) +static void master_fun(int argc, char* argv[]) { - unsigned int i; - sg_host_t* worker_pms = sg_actor_self_data(); - sg_vm_t* vms = (sg_vm_t*)malloc(2 * sizeof(sg_vm_t)); + sg_vm_t* vms = xbt_malloc(2 * sizeof(sg_vm_t)); /* Launch VMs and worker actors. One VM per PM, and one worker actor per VM. */ XBT_INFO("# Launch 2 VMs"); @@ -116,9 +114,9 @@ static void master_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[ sg_actor_sleep_for(10 - simgrid_get_clock()); XBT_INFO("# Add one more actor on each VM"); - for (unsigned int i = 0; i < 2; i++) { - char* vm_name = bprintf("VM%02u", i); - char* pr_name = bprintf("WRK%02u", i + 2); + for (int i = 0; i < 2; i++) { + char* vm_name = bprintf("VM%02d", i); + char* pr_name = bprintf("WRK%02d", i + 2); XBT_INFO("put an actor (%s) on %s", pr_name, vm_name); sg_actor_create(pr_name, (sg_host_t)vms[i], worker_fun, 0, NULL); @@ -144,11 +142,11 @@ static void master_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[ } XBT_INFO("# Shutdown the half of worker actors gracefully. The remaining half will be forcibly killed."); - for (i = 0; i < 2; i++) { + for (int i = 0; i < 2; i++) { char mbox_name[MAXMBOXLEN]; - snprintf(mbox_name, MAXMBOXLEN, "MBOX:WRK%02u", i); + snprintf(mbox_name, MAXMBOXLEN, "MBOX:WRK%02d", i); sg_mailbox_t mbox = sg_mailbox_by_name(mbox_name); - double* payload = (double*)malloc(sizeof(double)); + double* payload = xbt_malloc(sizeof(double)); *payload = FINALIZE; sg_mailbox_put(mbox, payload, 0); } @@ -187,7 +185,7 @@ int main(int argc, char* argv[]) /* the first pm is the master, the others are workers */ sg_host_t master_pm = pms[0]; - sg_host_t* worker_pms = (sg_host_t*)malloc(2 * sizeof(sg_host_t)); + sg_host_t* worker_pms = xbt_malloc(2 * sizeof(sg_host_t)); for (int i = 0; i < 2; i++) worker_pms[i] = pms[i + 1];