X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/df12bbc75c274351f3b3a628740e0b3270f08e18..aafaaf396698612d5174bb0780c0a548e5422d84:/examples/msg/cloud/masterslave_virtual_machines.c diff --git a/examples/msg/cloud/masterslave_virtual_machines.c b/examples/msg/cloud/masterslave_virtual_machines.c index 48a81d72b0..e1527eb61e 100644 --- a/examples/msg/cloud/masterslave_virtual_machines.c +++ b/examples/msg/cloud/masterslave_virtual_machines.c @@ -45,7 +45,8 @@ int master(int argc, char *argv[]) { int slaves_count = 10; msg_host_t *slaves = xbt_new(msg_host_t,10); - int i; + msg_vm_t vm; + unsigned int i; /* Retrive the hostnames constituting our playground today */ for (i = 1; i < argc; i++) { @@ -62,10 +63,15 @@ int master(int argc, char *argv[]) { argv[0] = xbt_strdup(slavename); argv[1] = bprintf("%d",i); argv[2] = NULL; - msg_vm_t vm = MSG_vm_start(slaves[i],2); + + char vmName[64]; + snprintf(vmName, 64, "vm_%d", i); + + msg_vm_t vm = MSG_vm_start(slaves[i],vmName,2); MSG_vm_bind(vm, MSG_process_create_with_arguments(slavename,slave_fun,NULL,slaves[i],2,argv)); } + xbt_dynar_t vms = MSG_vms_as_dynar(); XBT_INFO("Launched %ld VMs", xbt_dynar_length(vms)); @@ -74,21 +80,23 @@ int master(int argc, char *argv[]) { work_batch(slaves_count); XBT_INFO("Now suspend all VMs, just for fun"); - for (i=0;i=2, "slave processes need to be given their rank as parameter"); - mailbox_name=bprintf("Slave_%s",argv[1]); - + sprintf(mailbox_name,"Slave_%s",argv[1]); + XBT_INFO("Slave listenning on %s",argv[1]); while (1) { res = MSG_task_receive(&(task),mailbox_name); xbt_assert(res == MSG_OK, "MSG_task_get failed"); @@ -161,14 +174,13 @@ int slave_fun(int argc, char *argv[]) task = NULL; } - free(mailbox_name); return 0; } /* end_of_slave */ /** Main function */ int main(int argc, char *argv[]) { - MSG_error_t res = MSG_OK; + msg_error_t res = MSG_OK; xbt_dynar_t hosts_dynar; msg_host_t*hosts= xbt_new(msg_host_t,10); char**hostnames= xbt_new(char*,10); @@ -206,8 +218,9 @@ int main(int argc, char *argv[]) res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); - MSG_clean(); free(hosts); + for (i=0;i<10;i++) + free(hostnames[i]); free(hostnames); xbt_dynar_free(&hosts_dynar);