-/* Public interface to the Link datatype */
-
/* Copyright (c) 2018. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
You should not access directly to the fields of the pointed structure, but always use the provided API to interact
with actors.
*/
-
XBT_PUBLIC int sg_actor_get_PID(sg_actor_t actor);
XBT_PUBLIC int sg_actor_get_PPID(sg_actor_t actor);
XBT_PUBLIC sg_actor_t sg_actor_by_PID(aid_t pid);
XBT_PUBLIC void sg_actor_migrate(sg_actor_t process, sg_host_t host);
XBT_PUBLIC void sg_actor_join(sg_actor_t actor, double timeout);
XBT_PUBLIC void sg_actor_kill(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_kill_all();
XBT_PUBLIC void sg_actor_set_kill_time(sg_actor_t actor, double kill_time);
+XBT_PUBLIC void sg_actor_yield();
SG_END_DECL()
#endif /* INCLUDE_SIMGRID_ACTOR_H_ */
--- /dev/null
+/* Copyright (c) 2018. 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. */
+
+#ifndef INCLUDE_SIMGRID_ENGINE_H_
+#define INCLUDE_SIMGRID_ENGINE_H_
+
+#include <simgrid/forward.h>
+
+/* C interface */
+SG_BEGIN_DECL()
+XBT_PUBLIC void sg_engine_load_platform(const char* filename);
+XBT_PUBLIC void sg_engine_load_deployment(const char* filename);
+XBT_PUBLIC void sg_engine_register_function(const char* name, int (*code)(int, char**));
+XBT_PUBLIC void sg_engine_register_default(int (*code)(int, char**));
+XBT_PUBLIC double sg_engine_get_clock();
+SG_END_DECL()
+
+#endif /* INCLUDE_SIMGRID_ENGINE_H_ */
#define SIMGRID_MSG_H
#include <simgrid/actor.h>
+#include <simgrid/engine.h>
#include <simgrid/forward.h>
#include <simgrid/host.h>
#include <simgrid/instr.h>
XBT_PUBLIC void MSG_process_migrate(msg_process_t process, msg_host_t host);
XBT_PUBLIC void MSG_process_join(msg_process_t process, double timeout);
XBT_PUBLIC void MSG_process_kill(msg_process_t process);
+XBT_PUBLIC void MSG_process_killall();
XBT_PUBLIC void MSG_process_set_kill_time(msg_process_t process, double kill_time);
+XBT_PUBLIC void MSG_process_yield();
/* ******************************** File ************************************ */
typedef sg_file_t msg_file_t;
XBT_PUBLIC msg_process_t MSG_process_attach(const char* name, void* data, msg_host_t host, xbt_dict_t properties);
XBT_PUBLIC void MSG_process_detach();
-XBT_PUBLIC int MSG_process_killall();
-XBT_PUBLIC void MSG_process_yield();
-
XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
XBT_PUBLIC int MSG_process_self_PID();
XBT_PUBLIC int MSG_process_self_PPID();
+++ /dev/null
-/* Copyright (c) 2004-2018. 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/msg/msg_private.hpp"
-
-/** \ingroup msg_simulation
- * \brief An application deployer.
- *
- * Creates the process described in \a file.
- * \param file a filename of a xml description of the application. This file follows this DTD :
- *
- * \include simgrid.dtd
- *
- * Here is a small example of such a platform
- *
- * \include msg/masterslave/deployment_masterslave.xml
- *
- * Have a look in the directory examples/msg/ to have a bigger example.
- */
-void MSG_launch_application(const char *file)
-{
- xbt_assert(msg_global, "MSG_init has to be called before MSG_launch_application.");
- SIMIX_launch_application(file);
-}
-
-/** \ingroup msg_simulation
- * \brief Registers the main function of a process in a global table.
- *
- * Registers a code function in a global table.
- * This table is then used by #MSG_launch_application.
- * \param name the reference name of the function.
- * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
- */
-void MSG_function_register(const char *name, xbt_main_func_t code)
-{
- SIMIX_function_register(name, code);
-}
-
-/** \ingroup msg_simulation
- * \brief Registers a function as the default main function of processes.
- *
- * Registers a code function as being the default value. This function will get used by MSG_launch_application() when there is no registered function of the requested name in.
- * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
- */
-void MSG_function_register_default(xbt_main_func_t code)
-{
- SIMIX_function_register_default(code);
-}
-
-/**
- * \brief register functions bypassing the parser
- */
-
-void MSG_set_function(const char *host_id, const char *function_name, xbt_dynar_t arguments)
-{
- SIMIX_process_set_function(host_id, function_name, arguments, -1, -1);
-}
+++ /dev/null
-/* Copyright (c) 2004-2018. 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 "simgrid/msg.h"
-
-#if SIMGRID_HAVE_LUA
-#include <lua.h>
-#include <lauxlib.h>
-#include <lualib.h>
-#endif
-
-/********************************* MSG **************************************/
-
-/** \ingroup msg_simulation
- * \brief A platform constructor.
- *
- * Creates a new platform, including hosts, links and the routing_table.
- * \param file a filename of a xml description of a platform. This file follows this DTD :
- *
- * \include simgrid.dtd
- *
- * Here is a small example of such a platform
- *
- * \include small_platform.xml
- *
- * Have a look in the directory examples/msg/ to have a big example.
- */
-void MSG_create_environment(const char *file)
-{
- SIMIX_create_environment(file);
-}
/* 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 "simgrid/s4u/Actor.hpp"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
simgrid::config::set_as_string(key, value);
}
-/** \ingroup msg_simulation
- * \brief Kill all running process
-
- */
-int MSG_process_killall()
-{
- simgrid::s4u::Actor::kill_all();
- return 0;
-}
-
static void MSG_exit() {
if (msg_global==nullptr)
return;
msg_global = nullptr;
}
-/** \ingroup msg_simulation
- * \brief A clock (in second).
- */
-double MSG_get_clock()
+unsigned long int MSG_get_sent_msg()
{
- return SIMIX_get_clock();
+ return msg_global->sent_msg;
}
-unsigned long int MSG_get_sent_msg()
+/** \brief register functions bypassing the parser */
+void MSG_set_function(const char* host_id, const char* function_name, xbt_dynar_t arguments)
{
- return msg_global->sent_msg;
+ SIMIX_process_set_function(host_id, function_name, arguments, -1, -1);
}
#define MSG_CALL(type, oldname, args)
+/* ************************** Engine *************************** */
+void MSG_create_environment(const char* filename)
+{
+ sg_engine_load_platform(filename);
+}
+
+void MSG_launch_application(const char* filename)
+{
+ sg_engine_load_deployment(filename);
+}
+void MSG_function_register(const char* name, xbt_main_func_t code)
+{
+ sg_engine_register_function(name, code);
+}
+void MSG_function_register_default(xbt_main_func_t code)
+{
+ sg_engine_register_default(code);
+}
+double MSG_get_clock()
+{
+ return sg_engine_get_clock();
+}
/* ************************** Actors *************************** */
int MSG_process_get_PID(sg_actor_t actor)
{
{
sg_actor_kill(actor);
}
-
+void MSG_process_kill_all()
+{
+ sg_actor_kill_all();
+}
void MSG_process_set_kill_time(sg_actor_t actor, double kill_time)
{
sg_actor_set_kill_time(actor, kill_time);
}
+void MSG_process_yield()
+{
+ sg_actor_yield();
+}
/* ************************** NetZones *************************** */
sg_netzone_t MSG_zone_get_root()
SIMIX_process_detach();
}
-/** Yield the current actor; let the other actors execute first */
-void MSG_process_yield()
-{
- simgrid::simix::kernelImmediate([] { /* do nothing*/ });
-}
-
/** \ingroup m_process_management
* \brief Returns the user data of a process.
*
actor->kill();
}
+void sg_actor_kill_all()
+{
+ simgrid::s4u::Actor::kill_all();
+}
+
/** \ingroup m_actor_management
* \brief Set the kill time of an actor.
*
{
actor->set_kill_time(kill_time);
}
+
+/** Yield the current actor; let the other actors execute first */
+void sg_actor_yield()
+{
+ simgrid::s4u::this_actor::yield();
+}
}
} // namespace s4u
} // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+void sg_engine_load_platform(const char* file)
+{
+ simgrid::s4u::Engine::get_instance()->load_platform(file);
+}
+
+void sg_engine_load_deployment(const char* file)
+{
+ simgrid::s4u::Engine::get_instance()->load_deployment(file);
+}
+
+void sg_engine_register_function(const char* name, int (*code)(int, char**))
+{
+ simgrid::s4u::Engine::get_instance()->register_function(name, code);
+}
+void sg_engine_register_default(int (*code)(int, char**))
+{
+ simgrid::s4u::Engine::get_instance()->register_default(code);
+}
+double sg_engine_get_clock()
+{
+ return simgrid::s4u::Engine::get_clock();
+}
set(MSG_SRC
src/msg/instr_msg_process.cpp
src/msg/instr_msg_task.cpp
- src/msg/msg_deployment.cpp
- src/msg/msg_environment.cpp
src/msg/msg_global.cpp
src/msg/msg_gos.cpp
src/msg/msg_legacy.cpp
set(headers_to_install
include/simgrid/actor.h
+ include/simgrid/engine.h
include/simgrid/chrono.hpp
include/simgrid/plugins/dvfs.h
include/simgrid/plugins/energy.h