void *data);
XBT_PUBLIC(void *) MSG_task_get_data(m_task_t task);
XBT_PUBLIC(void) MSG_task_set_data(m_task_t task, void *data);
+XBT_PUBLIC(void) MSG_task_set_copy_callback(void (*callback) (
+ m_task_t task, m_process_t src, m_process_t dst));
XBT_PUBLIC(m_process_t) MSG_task_get_sender(m_task_t task);
XBT_PUBLIC(m_host_t) MSG_task_get_source(m_task_t task);
XBT_PUBLIC(const char *) MSG_task_get_name(m_task_t task);
msg_global->max_channel = 0;
msg_global->PID = 1;
msg_global->sent_msg = 0;
+ msg_global->task_copy_callback = NULL;
/* initialization of the action module */
_MSG_action_init();
SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
SIMIX_function_register_process_kill(MSG_process_kill_from_SIMIX);
+ SIMIX_comm_set_copy_data_callback(MSG_comm_copy_data_from_SIMIX);
}
#ifdef HAVE_TRACING
TRACE_start();
#include "xbt/log.h"
#include "xbt/sysdep.h"
-
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg,
"Logging specific to MSG (gos)");
return comm->task_received ? *comm->task_received : comm->task_sent;
}
+/**
+ * \brief This function is called by SIMIX to copy the data of a comm.
+ * \param comm the comm
+ * \param buff_size size of the buffer
+ */
+void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, size_t buff_size) {
+
+ // copy the task
+ SIMIX_comm_copy_pointer_callback(comm, buff_size);
+
+ // notify the user callback if any
+ if (msg_global->task_copy_callback) {
+ msg_global->task_copy_callback(SIMIX_req_comm_get_src_data(comm),
+ SIMIX_req_comm_get_src_proc(comm), SIMIX_req_comm_get_dst_proc(comm));
+ }
+}
+
/** \ingroup msg_gos_functions
* \brief Put a task on a channel of an host and waits for the end of the
* transmission.
TRY {
smx_action_t comm = SIMIX_req_comm_isend(mailbox, t_simdata->message_size,
t_simdata->rate, task, sizeof(void *),
- NULL, NULL, NULL, 0);
+ NULL, NULL, task, 0);
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
SIMIX_req_set_category(comm, task->category);
int PID;
int session;
unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
+ void (*task_copy_callback) (m_task_t task, m_process_t src, m_process_t dst);
} s_MSG_Global_t, *MSG_Global_t;
/*extern MSG_Global_t msg_global;*/
const char *hostname, int argc,
char **argv, xbt_dict_t properties);
void MSG_process_kill_from_SIMIX(smx_process_t p);
+void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, size_t buff_size);
void _MSG_action_init(void);
void _MSG_action_exit(void);
task->data = data;
}
+/** \ingroup m_task_management
+ * \brief Sets a function to be called when a task has just been copied.
+ * \param callback a callback function
+ */
+void MSG_task_set_copy_callback(void (*callback)
+ (m_task_t task, m_process_t sender, m_process_t receiver)) {
+ msg_global->task_copy_callback = callback;
+}
+
/** \ingroup m_task_management
* \brief Return the sender of a #m_task_t.
*