/********************************* MSG **************************************/
-static void _sg_cfg_cb_msg_multiple_backtraces(const char *name, int pos)
+static void _sg_cfg_cb_msg_debug_multiple_use(const char *name, int pos)
{
- msg_global->multiple_backtraces = xbt_cfg_get_boolean(_sg_cfg_set, name);
+ msg_global->debug_multiple_use = xbt_cfg_get_boolean(_sg_cfg_set, name);
}
/**
msg_global = xbt_new0(s_MSG_Global_t, 1);
- xbt_cfg_register(&_sg_cfg_set, "msg/multiple_backtraces",
- "Keep the severals backtraces",
- xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_msg_multiple_backtraces, NULL);
- xbt_cfg_setdefault_boolean(_sg_cfg_set, "msg/multiple_backtraces", "no");
+ xbt_cfg_register(&_sg_cfg_set, "msg/debug_multiple_use",
+ "Print backtraces of both processes when there is a conflict of multiple use of a task",
+ xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_msg_debug_multiple_use, NULL);
+ xbt_cfg_setdefault_boolean(_sg_cfg_set, "msg/debug_multiple_use", "no");
SIMIX_global_init(argc, argv);
TRY {
- if (msg_global->multiple_backtraces)
+ if (msg_global->debug_multiple_use)
MSG_BT(simdata->isused, "Using Backtrace");
else
simdata->isused = (void*)1;
p_simdata->waiting_action = NULL;
- simdata->isused=0;
+ if (msg_global->debug_multiple_use && simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+ simdata->isused = 0;
XBT_DEBUG("Execution task '%s' finished in state %d",
task->name, (int)comp_state);
t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
if (t_simdata->isused != 0) {
- if (msg_global->multiple_backtraces){
+ if (msg_global->debug_multiple_use){
XBT_ERROR("This task is already used in there:");
xbt_backtrace_display(t_simdata->isused);
- THROWF(unknown_error, 0, "And you try to reuse it from here. You cannot send it now. Go fix your code!");
+ XBT_ERROR("And you try to reuse it from here:");
+ xbt_backtrace_display_current();
} else {
- THROWF(unknown_error, 0, "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/multiple_backtraces:on to get the backtrace of the other process)");
+ xbt_assert(t_simdata->isused == 0,
+ "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)");
}
}
- if (msg_global->multiple_backtraces)
+ if (msg_global->debug_multiple_use)
MSG_BT(t_simdata->isused, "Using Backtrace");
else
t_simdata->isused = (void*)1;
if (finished && comm->task_received != NULL) {
/* I am the receiver */
- (*comm->task_received)->simdata->isused = 0;
+ simdata_task_t simdata = (*comm->task_received)->simdata;
+ if (msg_global->debug_multiple_use && simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+ simdata->isused = 0;
}
}
CATCH(e) {
if (status == MSG_OK && comm->task_received != NULL) {
/* I am the receiver */
- (*comm->task_received)->simdata->isused = 0;
+ simdata_task_t simdata = (*comm->task_received)->simdata;
+ if (msg_global->debug_multiple_use && simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+ simdata->isused = 0;
}
}
if (comm->task_received != NULL) {
/* I am the receiver */
- (*comm->task_received)->simdata->isused = 0;
+ simdata_task_t simdata = (*comm->task_received)->simdata;
+ if (msg_global->debug_multiple_use && simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+ simdata->isused = 0;
}
/* FIXME: these functions are not traceable */
if (comm->task_received != NULL) {
/* I am the receiver */
- (*comm->task_received)->simdata->isused = 0;
+ simdata_task_t simdata = (*comm->task_received)->simdata;
+ if (msg_global->debug_multiple_use && simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+ simdata->isused = 0;
}
return finished_index;
TRY {
simcall_comm_recv(mailbox, task, NULL, NULL, NULL, timeout, rate);
XBT_DEBUG("Got task %s from %p",(*task)->name,mailbox);
- (*task)->simdata->isused=0;
+ simdata_task_t simdata = (*task)->simdata;
+ if (msg_global->debug_multiple_use && simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+ simdata->isused = 0;
}
CATCH(e) {
switch (e.category) {
t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
if (t_simdata->isused != 0) {
- if (msg_global->multiple_backtraces){
+ if (msg_global->debug_multiple_use){
XBT_ERROR("This task is already used in there:");
xbt_backtrace_display(t_simdata->isused);
- THROWF(unknown_error, 0, "And you try to reuse it from here. You cannot send it now. Go fix your code!");
+ XBT_ERROR("And you try to reuse it from here:");
+ xbt_backtrace_display_current();
} else {
- THROWF(unknown_error, 0, "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/multiple_backtraces:on to get the backtrace of the other process)");
+ xbt_assert(t_simdata->isused == 0,
+ "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)");
}
}
- if (msg_global->multiple_backtraces)
+ if (msg_global->debug_multiple_use)
MSG_BT(t_simdata->isused, "Using Backtrace");
else
t_simdata->isused = (void*)1;
xbt_ex_free(e);
/* If the send failed, it is not used anymore */
+ if (msg_global->debug_multiple_use && t_simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)t_simdata->isused);
t_simdata->isused = 0;
}
int max_channel;
#endif
int session;
- int multiple_backtraces;
+ int debug_multiple_use;
unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
void_f_pvoid_t process_data_cleanup;
#include "xbt/log.h"
/** @addtogroup m_task_management
- *
- *
+ *
+ *
* Since most scheduling algorithms rely on a concept of task
* that can be either <em>computed</em> locally or
* <em>transferred</em> on another processor, it seems to be the
}
else if (task->simdata->comm) {
simcall_comm_cancel(task->simdata->comm);
- task->simdata->isused = 0;
+ simdata_task_t simdata = task->simdata;
+ if (msg_global->debug_multiple_use && simdata->isused!=0)
+ xbt_ex_free(*(xbt_ex_t*)simdata->isused);
+ simdata->isused = 0;
}
return MSG_OK;
}
* \brief set the amount data attached with a task #msg_task_t.
*
* \warning If the transfer is ongoing (already started and not finished),
- * it is not modified by this call.
+ * it is not modified by this call.
*/
void MSG_task_set_data_size(msg_task_t task,
/** \ingroup m_task_management
- * \brief Changes the priority of a computation task. This priority doesn't affect
+ * \brief Changes the priority of a computation task. This priority doesn't affect
* the transfer rate. A priority of 2 will make a task receive two times more
* cpu power than the other ones.
*