char *name; /* synchro name if any */
xbt_fifo_t simcalls; /* List of simcalls waiting for this synchro */
char *category = nullptr; /* For instrumentation */
+
+ virtual void suspend()=0;
+ virtual void resume()=0;
};
}} // namespace simgrid::simix
#else /* not C++ */
--- /dev/null
+/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "src/simix/SynchroComm.hpp"
+#include "src/surf/surf_interface.hpp"
+
+void simgrid::simix::Comm::suspend() {
+ /* FIXME: shall we suspend also the timeout synchro? */
+ if (surf_comm)
+ surf_comm->suspend();
+ /* in the other case, the action will be suspended on creation, in SIMIX_comm_start() */
+
+}
+
+void simgrid::simix::Comm::resume() {
+ /*FIXME: check what happen with the timeouts */
+ if (surf_comm)
+ surf_comm->resume();
+ /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
+}
#ifndef _SIMIX_SYNCHRO_COMM_HPP
#define _SIMIX_SYNCHRO_COMM_HPP
+#include "surf/surf.h"
#include "src/simix/Synchro.h"
typedef enum {
XBT_PUBLIC_CLASS Comm : public Synchro {
public:
+ void suspend();
+ void resume();
+
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 */
--- /dev/null
+/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "src/simix/SynchroExec.hpp"
+#include "src/surf/surf_interface.hpp"
+
+void simgrid::simix::Exec::suspend()
+{
+ if (surf_exec)
+ surf_exec->suspend();
+}
+
+void simgrid::simix::Exec::resume()
+{
+ if (surf_exec)
+ surf_exec->resume();
+}
#ifndef _SIMIX_SYNCHRO_EXEC_HPP
#define _SIMIX_SYNCHRO_EXEC_HPP
+#include "surf/surf.h"
#include "src/simix/Synchro.h"
namespace simgrid {
XBT_PUBLIC_CLASS Exec : public Synchro {
public:
+ void suspend();
+ void resume();
+
sg_host_t host; /* The host where the execution takes place */
surf_action_t surf_exec; /* The Surf execution action encapsulated */
};
--- /dev/null
+/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "src/simix/SynchroIo.hpp"
+#include "src/surf/surf_interface.hpp"
+
+void simgrid::simix::Io::suspend()
+{
+ if (surf_io)
+ surf_io->suspend();
+}
+
+void simgrid::simix::Io::resume()
+{
+ if (surf_io)
+ surf_io->resume();
+}
#ifndef _SIMIX_SYNCHRO_IO_HPP
#define _SIMIX_SYNCHRO_IO_HPP
+#include "surf/surf.h"
#include "src/simix/Synchro.h"
namespace simgrid {
XBT_PUBLIC_CLASS Io : public Synchro {
public:
+ void suspend();
+ void resume();
+
sg_host_t host;
surf_action_t surf_io;
};
--- /dev/null
+/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "src/simix/SynchroRaw.hpp"
+#include "src/surf/surf_interface.hpp"
+
+void simgrid::simix::Raw::suspend() {
+ /* The suspension of raw synchros is delayed to when the process is rescheduled. */
+}
+
+void simgrid::simix::Raw::resume() {
+ /* I cannot resume raw synchros directly. This is delayed to when the process is rescheduled at
+ * the end of the synchro. */
+}
#ifndef _SIMIX_SYNCHRO_RAW_HPP
#define _SIMIX_SYNCHRO_RAW_HPP
+#include "surf/surf.h"
#include "src/simix/Synchro.h"
namespace simgrid {
/** Used to implement mutexes, semaphores and conditions */
XBT_PUBLIC_CLASS Raw : public Synchro {
public:
+ void suspend();
+ void resume();
+
surf_action_t sleep;
};
--- /dev/null
+/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "src/simix/SynchroSleep.hpp"
+#include "src/surf/surf_interface.hpp"
+
+void simgrid::simix::Sleep::suspend() {
+ surf_sleep->suspend();
+}
+
+void simgrid::simix::Sleep::resume() {
+ surf_sleep->resume();
+}
#ifndef _SIMIX_SYNCHRO_SLEEP_HPP
#define _SIMIX_SYNCHRO_SLEEP_HPP
+#include "surf/surf.h"
#include "src/simix/Synchro.h"
namespace simgrid {
XBT_PUBLIC_CLASS Sleep : public Synchro {
public:
+ void suspend();
+ void resume();
+
sg_host_t host; /* The host that is sleeping */
surf_action_t surf_sleep; /* The Surf sleeping action encapsulated */
};
void SIMIX_execution_suspend(smx_synchro_t synchro)
{
- simgrid::simix::Exec *exec = static_cast<simgrid::simix::Exec *>(synchro);
- if(exec->surf_exec)
- exec->surf_exec->suspend();
+ synchro->suspend(); // FIXME: USELESS
}
void SIMIX_execution_resume(smx_synchro_t synchro)
{
- simgrid::simix::Exec *exec = static_cast<simgrid::simix::Exec *>(synchro);
- if(exec->surf_exec)
- exec->surf_exec->resume();
+ synchro->resume(); // FIXME: USELESS
}
void SIMIX_execution_finish(smx_synchro_t synchro)
void SIMIX_comm_suspend(smx_synchro_t synchro)
{
- simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
-
- /*FIXME: shall we suspend also the timeout synchro? */
- if (comm->surf_comm)
- comm->surf_comm->suspend();
- /* in the other case, the action will be suspended on creation, in SIMIX_comm_start() */
+ synchro->suspend(); // FIXME: USELESS
}
void SIMIX_comm_resume(smx_synchro_t synchro)
{
- simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
-
- /*FIXME: check what happen with the timeouts */
- if (comm->surf_comm)
- comm->surf_comm->resume();
- /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
+ synchro->resume(); // FIXME: USELESS
}
smx_synchro_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer)
{
- xbt_assert((process != NULL), "Invalid parameters");
-
if (process->suspended) {
XBT_DEBUG("Process '%s' is already suspended", process->name);
return NULL;
process->suspended = 1;
- /* If we are suspending another process, and it is waiting on a sync, suspend its synchronization. */
+ /* If we are suspending another process that is waiting on a sync, suspend its synchronization. */
if (process != issuer) {
- if (process->waiting_synchro) {
-
- simgrid::simix::Exec *exec = dynamic_cast<simgrid::simix::Exec*>(process->waiting_synchro);
- if (exec != nullptr) {
- SIMIX_execution_suspend(process->waiting_synchro);
- }
-
- simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>(process->waiting_synchro);
- if (comm != nullptr) {
- SIMIX_comm_suspend(process->waiting_synchro);
- }
-
- simgrid::simix::Sleep *sleep = dynamic_cast<simgrid::simix::Sleep*>(process->waiting_synchro);
- if (sleep != nullptr) {
- SIMIX_process_sleep_suspend(process->waiting_synchro);
- }
+ if (process->waiting_synchro)
+ process->waiting_synchro->suspend();
+ /* If the other process is not waiting, its suspension is delayed to when the process is rescheduled. */
- /* The suspension of raw synchros is delayed to when the process is rescheduled. */
- return NULL;
- } else {
- /* If the other process is not waiting, its suspension is delayed to when the process is rescheduled. */
- return NULL;
- }
+ return NULL;
} else {
/* FIXME: computation size is zero. Is it okay that bound is zero ? */
return SIMIX_execution_start(process, "suspend", 0.0, 1.0, 0.0, 0);
if (process != issuer) {
if (process->waiting_synchro) {
- simgrid::simix::Exec *exec = dynamic_cast<simgrid::simix::Exec*>(process->waiting_synchro);
- if (exec != nullptr) {
- SIMIX_execution_resume(process->waiting_synchro);
- }
-
- simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>(process->waiting_synchro);
- if (comm != nullptr) {
- SIMIX_comm_resume(process->waiting_synchro);
- }
-
- simgrid::simix::Sleep *sleep = dynamic_cast<simgrid::simix::Sleep*>(process->waiting_synchro);
- if (sleep != nullptr) {
- SIMIX_process_sleep_resume(process->waiting_synchro);
- }
-
- /* I cannot resume raw synchros now. This is delayed to when the process is rescheduled at
- * the end of the synchro. */
-
+ process->waiting_synchro->resume();
}
} else XBT_WARN("Strange. Process %p is trying to resume himself.", issuer);
void SIMIX_process_sleep_suspend(smx_synchro_t synchro)
{
- simgrid::simix::Sleep *sleep = static_cast<simgrid::simix::Sleep*>(synchro);
- sleep->surf_sleep->suspend();
+ synchro->suspend(); //FIXME: USELESS
}
void SIMIX_process_sleep_resume(smx_synchro_t synchro)
{
- XBT_DEBUG("Synchro state is %d on process_sleep_resume.", synchro->state);
- simgrid::simix::Sleep *sleep = static_cast<simgrid::simix::Sleep*>(synchro);
-
- sleep->surf_sleep->resume();
+ synchro->resume(); //FIXME: USELESS
}
/**
src/simix/smx_vm.cpp
src/simix/popping.cpp
src/simix/Synchro.cpp
+ src/simix/SynchroComm.cpp
+ src/simix/SynchroExec.cpp
+ src/simix/SynchroSleep.cpp
+ src/simix/SynchroRaw.cpp
+ src/simix/SynchroIo.cpp
${SIMIX_GENERATED_SRC}
)