int i;
msg_task_t task;
char mailbox[256];
- char sprintf_buffer[256];
+ char snprintf_buffer[256];
msg_comm_t comm;
for (i = 0; i < number_of_tasks; i++) {
else
coef = (i + 1);
- sprintf(mailbox, "receiver-%ld", (i % receivers_count));
- sprintf(sprintf_buffer, "Task_%d", i);
- task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size / coef, NULL);
+ snprintf(mailbox,255, "receiver-%ld", (i % receivers_count));
+ snprintf(snprintf_buffer,255, "Task_%d", i);
+ task = MSG_task_create(snprintf_buffer, task_comp_size, task_comm_size / coef, NULL);
comm = MSG_task_isend(task, mailbox);
xbt_dynar_push_as(d, msg_comm_t, comm);
- XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, sprintf_buffer, task_comm_size / coef);
+ XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, snprintf_buffer, task_comm_size / coef);
}
/* Here we are waiting for the completion of all communications */
- while (!xbt_dynar_is_empty(d)) {
+ while (xbt_dynar_is_empty(d) == 0) {
xbt_dynar_remove_at(d, MSG_comm_waitany(d), &comm);
MSG_comm_destroy(comm);
}
xbt_dynar_free(&d);
/* Here we are waiting for the completion of all tasks */
- sprintf(mailbox, "finalize");
-
msg_comm_t res_irecv;
XBT_ATTRIB_UNUSED msg_error_t res_wait;
for (i = 0; i < receivers_count; i++) {
task = NULL;
- res_irecv = MSG_task_irecv(&(task), mailbox);
+ res_irecv = MSG_task_irecv(&(task), "finalize");
res_wait = MSG_comm_wait(res_irecv, -1);
xbt_assert(res_wait == MSG_OK, "MSG_comm_wait failed");
MSG_comm_destroy(res_irecv);
XBT_ATTRIB_UNUSED int read;
read = sscanf(argv[1], "%d", &id);
xbt_assert(read, "Invalid argument %s\n", argv[1]);
- sprintf(mailbox, "receiver-%d", id);
+ snprintf(mailbox,79, "receiver-%d", id);
MSG_process_sleep(10);
msg_comm_t res_irecv;
for (int i = 0; i < tasks; i++) {
xbt_free(task);
/* Here we tell to sender that all tasks are done */
- sprintf(mailbox, "finalize");
- res_irecv = MSG_task_isend(MSG_task_create(NULL, 0, 0, NULL), mailbox);
+ res_irecv = MSG_task_isend(MSG_task_create(NULL, 0, 0, NULL), "finalize");
MSG_comm_wait(res_irecv, -1);
MSG_comm_destroy(res_irecv);
XBT_INFO("I'm done. See you!");