Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Add a `run_blocking` simcall and simix::kernelSync
[simgrid.git] / src / simix / libsmx.cpp
index 8e07b0c..e91ebb8 100644 (file)
 
 #include <xbt/functional.hpp>
 
+#include <simgrid/simix/blocking_simcall.hpp>
+
 #include "src/mc/mc_replay.h"
 #include "smx_private.h"
 #include "src/mc/mc_forward.hpp"
 #include "xbt/ex.h"
 #include "mc/mc.h"
 #include "src/simix/smx_host_private.h"
-
 #include "src/simix/SynchroComm.hpp"
 
 #include <simgrid/simix.hpp>
@@ -351,44 +352,6 @@ void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t d
     SIMIX_vm_migratefrom_resumeto, vm, src_pm, dst_pm));
 }
 
-/**
- * \ingroup simix_process_management
- * \brief Creates and runs a new SIMIX process.
- *
- * The structure and the corresponding thread are created and put in the list of ready processes.
- *
- * \param name a name for the process. It is for user-level information and can be nullptr.
- * \param code the main function of the process
- * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be nullptr.
- * It can be retrieved with the function \ref simcall_process_get_data.
- * \param hostname name of the host where the new agent is executed.
- * \param kill_time time when the process is killed
- * \param argc first argument passed to \a code
- * \param argv second argument passed to \a code
- * \param properties the properties of the process
- * \param auto_restart either it is autorestarting or not.
- */
-smx_process_t simcall_process_create(const char *name,
-                              xbt_main_func_t code,
-                              void *data,
-                              const char *hostname,
-                              double kill_time,
-                              int argc, char **argv,
-                              xbt_dict_t properties,
-                              int auto_restart)
-{
-  if (name == nullptr)
-    name = "";
-  auto wrapped_code = simgrid::xbt::wrapMain(code, argc, argv);
-  for (int i = 0; i != argc; ++i)
-    xbt_free(argv[i]);
-  xbt_free(argv);
-  smx_process_t res = simcall_process_create(name,
-    std::move(wrapped_code),
-    data, hostname, kill_time, properties, auto_restart);
-  return res;
-}
-
 /**
  * \ingroup simix_process_management
  * \brief Kills a SIMIX process.
@@ -1131,6 +1094,11 @@ void simcall_run_kernel(std::function<void()> const& code)
   return simcall_BODY_run_kernel(&code);
 }
 
+void simcall_run_blocking(std::function<void()> const& code)
+{
+  return simcall_BODY_run_blocking(&code);
+}
+
 int simcall_mc_random(int min, int max) {
   return simcall_BODY_mc_random(min, max);
 }
@@ -1141,3 +1109,15 @@ int simcall_mc_random(int min, int max) {
 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
   return simcall_names[kind];
 }
+
+namespace simgrid {
+namespace simix {
+
+void unblock(smx_process_t process)
+{
+  xbt_assert(SIMIX_is_maestro());
+  SIMIX_simcall_answer(&process->simcall);
+}
+
+}
+}
\ No newline at end of file