char mailbox[256];
msg_task_t task = NULL;
msg_comm_t comm = NULL;
+ xbt_ex_t ex;
+
sprintf(mailbox, "jupi");
task = MSG_task_create("normal", task_comp_size, task_comm_size, NULL);
task = MSG_task_create("cancel directly", task_comp_size, task_comm_size, NULL);
XBT_INFO("Canceling task \"%s\" directly", task->name);
MSG_task_cancel(task);
+ MSG_task_destroy(task);
task = MSG_task_create("destroy directly", task_comp_size, task_comm_size, NULL);
XBT_INFO("Destroying task \"%s\" directly", task->name);
comm = MSG_task_isend(task, mailbox);
XBT_INFO("Canceling task \"%s\" during comm", task->name);
MSG_task_cancel(task);
+ TRY {
+ MSG_comm_wait(comm, -1);
+ }
+ CATCH (ex) {
+ xbt_ex_free(ex);
+ MSG_comm_destroy(comm);
+ }
+ MSG_task_destroy(task);
task = MSG_task_create("finalize", task_comp_size, task_comm_size, NULL);
comm = MSG_task_isend(task, mailbox);
XBT_INFO("Destroying task \"%s\" during comm", task->name);
MSG_task_destroy(task);
+ TRY {
+ MSG_comm_wait(comm, -1);
+ }
+ CATCH (ex) {
+ xbt_ex_free(ex);
+ MSG_comm_destroy(comm);
+ }
task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
MSG_task_send_with_timeout(task, mailbox, timeout);
static int worker_main(int argc, char *argv[])
{
msg_task_t task = MSG_process_get_data(MSG_process_self());
+ msg_error_t res;
XBT_INFO("Start %s", task->name);
- MSG_task_execute(task);
- XBT_INFO("Task done");
+ res = MSG_task_execute(task);
+ XBT_INFO("Task %s", res == MSG_OK ? "done" : "failed");
+ MSG_task_destroy(task);
return 0;
}
/** Receiver function */
int slave(int argc, char *argv[])
{
- msg_task_t task = NULL;
+ msg_task_t task;
_XBT_GNUC_UNUSED int res;
int id = -1;
char mailbox[80];
- _XBT_GNUC_UNUSED int read;
- double duration, start, end;
+ double start, end;
sprintf(mailbox, "jupi");
while (1) {
+ task = NULL;
res = MSG_task_receive(&(task), mailbox);
xbt_assert(res == MSG_OK, "MSG_task_get failed");
- XBT_INFO("Handleling task \"%s\"", MSG_task_get_name(task));
+ XBT_INFO("Handling task \"%s\"", MSG_task_get_name(task));
if (!strcmp(MSG_task_get_name(task), "finalize")) {
XBT_INFO("Destroying task \"%s\"", task->name);
continue;
}
- duration = MSG_task_get_compute_duration(task);
start = MSG_get_clock();
MSG_task_execute(task);
end = MSG_get_clock();
const char *application_file;
MSG_init(&argc, argv);
- if (argc < 2) {
+ if (argc != 3) {
printf("Usage: %s platform_file deployment_file\n", argv[0]);
printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
exit(1);
}
platform_file = argv[1];
- application_file = argv[1];
+ application_file = argv[2];
/* MSG_config("workstation/model","KCCFLN05"); */
{ /* Simulation setting */