#include "src/simix/SynchroComm.hpp"
#include "src/surf/surf_interface.hpp"
+#include "src/simix/smx_network_private.h"
+#include "simgrid/modelchecker.h"
+#include "src/mc/mc_replay.h"
+
void simgrid::simix::Comm::suspend() {
/* FIXME: shall we suspend also the timeout synchro? */
surf_comm->resume();
/* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
}
+
+void simgrid::simix::Comm::cancel() {
+ /* if the synchro is a waiting state means that it is still in a mbox */
+ /* so remove from it and delete it */
+ if (state == SIMIX_WAITING) {
+ SIMIX_mbox_remove(mbox, this);
+ state = SIMIX_CANCELED;
+ }
+ else if (!MC_is_active() /* when running the MC there are no surf actions */
+ && !MC_record_replay_is_active()
+ && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
+
+ surf_comm->cancel();
+ }
+}
public:
void suspend();
void resume();
+ void cancel();
e_smx_comm_type_t type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
smx_mailbox_t mbox; /* Rendez-vous where the comm is queued */
#include "mc/mc.h"
#include "src/simix/smx_host_private.h"
+#include "src/simix/SynchroComm.hpp"
+
#include <simgrid/simix.hpp>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
/**
* \ingroup simix_comm_management
*/
-void simcall_comm_cancel(smx_synchro_t comm)
+void simcall_comm_cancel(smx_synchro_t synchro)
{
- simcall_BODY_comm_cancel(comm);
+ simgrid::simix::kernel([synchro]{
+ simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
+ comm->cancel();
+ });
}
/**
simcall->result.dp = result;
}
-static inline smx_synchro_t simcall_comm_cancel__get__comm(smx_simcall_t simcall) {
- return (smx_synchro_t) simcall->args[0].dp;
-}
-static inline void simcall_comm_cancel__set__comm(smx_simcall_t simcall, void* arg) {
- simcall->args[0].dp = arg;
-}
-
static inline xbt_dynar_t simcall_comm_waitany__get__comms(smx_simcall_t simcall) {
return (xbt_dynar_t) simcall->args[0].dp;
}
return (smx_synchro_t) self->simcall.result.dp;
}
-inline static void simcall_BODY_comm_cancel(smx_synchro_t comm) {
- smx_process_t self = SIMIX_process_self();
-
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_comm_cancel(comm);
- /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
-
- self->simcall.call = SIMCALL_COMM_CANCEL;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) comm;
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
- } else {
- SIMIX_simcall_handle(&self->simcall, 0);
- }
-
- }
-
inline static int simcall_BODY_comm_waitany(xbt_dynar_t comms) {
smx_process_t self = SIMIX_process_self();
SIMCALL_COMM_ISEND,
SIMCALL_COMM_RECV,
SIMCALL_COMM_IRECV,
- SIMCALL_COMM_CANCEL,
SIMCALL_COMM_WAITANY,
SIMCALL_COMM_WAIT,
SIMCALL_COMM_TEST,
"SIMCALL_COMM_ISEND",
"SIMCALL_COMM_RECV",
"SIMCALL_COMM_IRECV",
- "SIMCALL_COMM_CANCEL",
"SIMCALL_COMM_WAITANY",
"SIMCALL_COMM_WAIT",
"SIMCALL_COMM_TEST",
SIMIX_simcall_answer(simcall);
break;
-case SIMCALL_COMM_CANCEL:
- SIMIX_comm_cancel((smx_synchro_t) simcall->args[0].dp);
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_COMM_WAITANY:
simcall_HANDLER_comm_waitany(simcall , (xbt_dynar_t) simcall->args[0].dp);
break;
Func H comm_isend (void*, smx_synchro_t) (sender, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, FPtr, simix_match_func_t) (clean_fun, FPtr, simix_clean_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (detached, int)
Blck H comm_recv (void) (receiver, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (timeout, double) (rate, double)
Func H comm_irecv (void*, smx_synchro_t) (receiver, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (rate, double)
-Proc - comm_cancel (void) (comm, void*, smx_synchro_t)
Blck H comm_waitany (int) (comms, void*, xbt_dynar_t)
Blck H comm_wait (void) (comm, void*, smx_synchro_t) (timeout, double)
Blck H comm_test (int) (comm, void*, smx_synchro_t)
}
}
-void SIMIX_comm_cancel(smx_synchro_t synchro)
-{
- simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
-
- /* if the synchro is a waiting state means that it is still in a mbox */
- /* so remove from it and delete it */
- if (comm->state == SIMIX_WAITING) {
- SIMIX_mbox_remove(comm->mbox, synchro);
- comm->state = SIMIX_CANCELED;
- }
- else if (!MC_is_active() /* when running the MC there are no surf actions */
- && !MC_record_replay_is_active()
- && (comm->state == SIMIX_READY || comm->state == SIMIX_RUNNING)) {
-
- comm->surf_comm->cancel();
- }
-}
-
/************* synchro Getters **************/
/**
XBT_PRIVATE smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src,
int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data);
XBT_PRIVATE void SIMIX_post_comm(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_comm_cancel(smx_synchro_t synchro);
XBT_PRIVATE double SIMIX_comm_get_remains(smx_synchro_t synchro);
XBT_PRIVATE e_smx_state_t SIMIX_comm_get_state(smx_synchro_t synchro);
XBT_PRIVATE smx_process_t SIMIX_comm_get_src_proc(smx_synchro_t synchro);
/* make sure no one will finish the comm after this process is destroyed,
* because src_proc or dst_proc would be an invalid pointer */
- SIMIX_comm_cancel(comm);
+ comm->cancel();
if (comm->src_proc == process) {
XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d, src = %p, dst = %p",
} else if (comm != nullptr) {
xbt_fifo_remove(process->comms, process->waiting_synchro);
- SIMIX_comm_cancel(process->waiting_synchro);
+ comm->cancel();
xbt_fifo_remove(process->waiting_synchro->simcalls, &process->simcall);
SIMIX_comm_destroy(process->waiting_synchro);
simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>(process->waiting_synchro);
if (comm != nullptr) {
- xbt_fifo_remove(process->comms, process->waiting_synchro);
- SIMIX_comm_cancel(process->waiting_synchro);
+ xbt_fifo_remove(process->comms, comm);
+ comm->cancel();
}
simgrid::simix::Sleep *sleep = dynamic_cast<simgrid::simix::Sleep*>(process->waiting_synchro);