xbt_replay_action_register("read", action_read);
xbt_replay_action_register("close", action_close);
- if (!opened_files)
+ if (opened_files == NULL)
opened_files = xbt_dict_new_homogeneous(NULL);
/* Actually do the simulation using MSG_action_trace_run */
res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here
message_t msg = MSG_task_get_data(task);
XBT_DEBUG("Peer %s got message of type %d\n", peer->me, msg->type);
- switch (msg->type) {
- case MESSAGE_BUILD_CHAIN:
- peer_init_chain(peer, msg);
- break;
- case MESSAGE_SEND_DATA:
- xbt_assert(peer->init, "peer_execute_task() failed: got msg_type %d before initialization", msg->type);
- if (peer->next != NULL)
- peer_forward_msg(peer, msg);
- peer->pieces++;
- peer->bytes += msg->data_length;
- if (peer->pieces >= peer->total_pieces) {
- XBT_DEBUG("%d pieces receieved", peer->pieces);
- done = 1;
- }
- break;
+ if (msg->type == MESSAGE_BUILD_CHAIN)
+ peer_init_chain(peer, msg);
+ if (msg->type == MESSAGE_SEND_DATA){
+ xbt_assert(peer->init, "peer_execute_task() failed: got msg_type %d before initialization", msg->type);
+ if (peer->next != NULL)
+ peer_forward_msg(peer, msg);
+ peer->pieces++;
+ peer->bytes += msg->data_length;
+ if (peer->pieces >= peer->total_pieces) {
+ XBT_DEBUG("%d pieces receieved", peer->pieces);
+ done = 1;
+ }
}
MSG_task_execute(task);
msg_error_t status;
msg_comm_t comm = NULL;
msg_task_t task = NULL;
- int idx = -1;
int done = 0;
- while (!done) {
+ while (done == 0) {
comm = MSG_task_irecv(&task, peer->me);
queue_pending_connection(comm, peer->pending_recvs);
-
- if ((idx = MSG_comm_waitany(peer->pending_recvs)) != -1) {
+ int idx = MSG_comm_waitany(peer->pending_recvs);
+ if (idx != -1) {
comm = xbt_dynar_get_as(peer->pending_recvs, idx, msg_comm_t);
status = MSG_comm_get_status(comm);
XBT_DEBUG("peer_wait_for_message: error code = %d", status);
/** Peer function */
int peer(int argc, char *argv[])
{
- float start_time, end_time;
peer_t p = xbt_new(s_peer_t, 1);
msg_error_t status;
XBT_DEBUG("peer");
peer_init(p, argc, argv);
- start_time = MSG_get_clock();
+ float start_time = MSG_get_clock();
status = peer_wait_for_message(p);
peer_shutdown(p);
- end_time = MSG_get_clock();
+ float end_time = MSG_get_clock();
peer_print_stats(p, end_time - start_time);
peer_delete(p);
int res = MSG_task_receive(&(task), mailbox);
xbt_assert(res == MSG_OK, "MSG_task_get failed");
-// XBT_INFO("Received \"%s\"", MSG_task_get_name(task));
- if (!strcmp(MSG_task_get_name(task), "finalize")) {
+ if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
MSG_task_destroy(task); /* - Exit if 'finalize' is received */
break;
}
-// XBT_INFO("Processing \"%s\"", MSG_task_get_name(task));
MSG_task_execute(task); /* - Otherwise, process the task */
-// XBT_INFO("\"%s\" done", MSG_task_get_name(task));
MSG_task_destroy(task);
task = NULL;
}
msg_task_t task = NULL;
msg_error_t res = MSG_task_receive(&task, mbox);
- if (res != MSG_OK) {
- XBT_CRITICAL("MSG_task_get failed");
- DIE_IMPOSSIBLE;
- }
+ xbt_assert(res == MSG_OK, "MSG_task_get failed");
XBT_INFO("%s received task(%s) from mailbox(%s)", pr_name, MSG_task_get_name(task), mbox);
- if (!strcmp(MSG_task_get_name(task), "finalize")) {
+ if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
MSG_task_destroy(task);
break;
}
XBT_INFO("# Suspend all VMs");
xbt_dynar_foreach(vms, i, vm) {
- const char *vm_name = MSG_host_get_name(vm);
- XBT_INFO("suspend %s", vm_name);
+ XBT_INFO("suspend %s", MSG_host_get_name(vm));
MSG_vm_suspend(vm);
}
MSG_vm_migrate(vm, worker_pm1);
}
- XBT_INFO("# Shutdown the half of worker processes gracefuly. The remaining half will be forcibly killed.");
+ XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
for (i = 0; i < nb_workers; i++) {
char mbox[MAXMBOXLEN];
snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02d", i);
> [Jacquelin:master:(1) 3567.161124] [msg_test/INFO] # Migrate all VMs to PM(Provost)
> [Intel:__pr_mig_tx:VM00(Intel-Provost):(11) 3567.161124] [msg_vm/WARNING] use the default max_downtime value 30ms
> [Intel:__pr_mig_tx:VM01(Intel-Provost):(13) 6034.900487] [msg_vm/WARNING] use the default max_downtime value 30ms
-> [Jacquelin:master:(1) 8502.639850] [msg_test/INFO] # Shutdown the half of worker processes gracefuly. The remaining half will be forcibly killed.
+> [Jacquelin:master:(1) 8502.639850] [msg_test/INFO] # Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.
> [VM00:WRK00:(2) 8504.519504] [msg_test/INFO] WRK00 received task(finalize) from mailbox(MBOX:WRK00)
> [VM01:WRK01:(3) 8506.399157] [msg_test/INFO] WRK01 received task(finalize) from mailbox(MBOX:WRK01)
> [Jacquelin:master:(1) 8506.399157] [msg_test/INFO] # Wait a while before effective shutdown.
*/
unsigned int answer_merge(answer_t destination, answer_t source)
{
- node_contact_t contact, contact_copy;
+ node_contact_t contact;
+ node_contact_t contact_copy;
unsigned int cpt;
unsigned int nb_added = 0;
/* TODO: Check if same destination */
xbt_dynar_foreach(source->nodes, cpt, contact) {
- if (!answer_contains(destination, contact->id)) {
+ if (answer_contains(destination, contact->id) == 0) {
contact_copy = node_contact_copy(contact);
xbt_dynar_push(destination->nodes, &contact_copy);
destination->size++;
void answer_add_bucket(bucket_t bucket, answer_t answer)
{
unsigned int cpt;
- unsigned int id, distance;
+ unsigned int id;
+ unsigned int distance;
node_contact_t contact;
xbt_assert((bucket != NULL), "Provided a NULL bucket");
xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL");
while (1) {
MSG_task_receive(&(task), "master_mailbox");
- if (!strcmp(MSG_task_get_name(task), "finalize")) {
+ if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
MSG_task_destroy(task);
break;
}
}
//create a customized viva graph configuration file
- FILE *fp;
+ FILE *fp = NULL;
fp = fopen ("viva_graph.plist", "w");
- if (!fp){
+ if (fp == NULL){
return 1;
}
fprintf (fp, "{\n node = (");
while (1) {
MSG_task_receive(&(task), "master_mailbox");
- if (!strcmp(MSG_task_get_name(task), "finalize")) {
+ if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
MSG_task_destroy(task);
break;
}
MSG_task_receive(&(task), "master_mailbox");
destination = (char*)MSG_task_get_data (task);
MSG_task_destroy (task);
- if (!destination) break; //there is no destination, die
+ if (destination == NULL)
+ break; //there is no destination, die
MSG_process_migrate(MSG_process_self(), MSG_host_by_name(destination));
MSG_process_sleep(2); // I am tired, have to sleep for 2 seconds
free (destination);
unsigned int i;
xbt_dynar_foreach(destinations, i, destination){
task = MSG_task_create("task", 0, 0, NULL);
- if (destination){
+ if (destination != NULL){
MSG_task_set_data(task, xbt_strdup (destination));
}
MSG_task_set_category(task, "migration_order");
SD_task_watch(c3, SD_DONE);
SD_task_watch(t4, SD_DONE);
- while (!xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0)))) {
+ while (xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0))) == 0) {
XBT_INFO("link1: bw=%.0f, lat=%f", SD_route_get_bandwidth(hosts[0], hosts[1]),
SD_route_get_latency(hosts[0], hosts[1]));
XBT_INFO("Jupiter: speed=%.0f", sg_host_speed(hosts[0])* sg_host_get_available_speed(hosts[0]));