--- /dev/null
+/* 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
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef INCLUDE_SIMGRID_ACTOR_H_
+#define INCLUDE_SIMGRID_ACTOR_H_
+
+#include <simgrid/forward.h>
+#include <xbt/base.h>
+#include <xbt/dict.h>
+
+/* C interface */
+SG_BEGIN_DECL()
+/** @brief Actor datatype.
+ @ingroup m_actor_management
+
+ An actor may be defined as a <em>code</em>, with some <em>private data</em>, executing in a <em>location</em>.
+
+ 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 const char* sg_actor_get_name(sg_actor_t actor);
+XBT_PUBLIC sg_host_t sg_actor_get_host(sg_actor_t actor);
+XBT_PUBLIC const char* sg_actor_get_property_value(sg_actor_t actor, const char* name);
+XBT_PUBLIC xbt_dict_t sg_actor_get_properties(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_suspend(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_resume(sg_actor_t actor);
+XBT_PUBLIC int sg_actor_is_suspended(sg_actor_t actor);
+XBT_PUBLIC sg_actor_t sg_actor_restart(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
+
+SG_END_DECL()
+
+#endif /* INCLUDE_SIMGRID_ACTOR_H_ */
typedef s4u_Storage* sg_storage_t;
typedef s4u_File* sg_file_t;
typedef s4u_VM* sg_vm_t;
+typedef s4u_Actor* sg_actor_t;
typedef routing_NetPoint* sg_netpoint_t;
typedef surf_Resource *sg_resource_t;
#ifndef SIMGRID_MSG_H
#define SIMGRID_MSG_H
+#include <simgrid/actor.h>
#include <simgrid/forward.h>
#include <simgrid/host.h>
#include <simgrid/instr.h>
#define msg_as_t msg_netzone_t /* portability macro */
typedef sg_netzone_t msg_netzone_t;
-#define MSG_zone_get_root() sg_zone_get_root()
-#define MSG_zone_get_name(zone) sg_zone_get_name(zone)
-#define MSG_zone_get_by_name(name) sg_zone_get_by_name(name)
-#define MSG_zone_get_sons(zone, whereto) sg_zone_get_sons(zone, whereto)
-#define MSG_zone_get_property_value(zone, name) sg_zone_get_property_value(zone, name)
-#define MSG_zone_set_property_value(zone, name, value) sg_zone_set_property_value(zone, name, value)
-#define MSG_zone_get_hosts(zone, whereto) sg_zone_get_hosts(zone, whereto)
+XBT_PUBLIC msg_netzone_t MSG_zone_get_root();
+XBT_PUBLIC const char* MSG_zone_get_name(msg_netzone_t zone);
+XBT_PUBLIC msg_netzone_t MSG_zone_get_by_name(const char* name);
+XBT_PUBLIC void MSG_zone_get_sons(msg_netzone_t zone, xbt_dict_t whereto);
+XBT_PUBLIC const char* MSG_zone_get_property_value(msg_netzone_t zone, const char* name);
+XBT_PUBLIC void MSG_zone_set_property_value(msg_netzone_t zone, const char* name, char* value);
+XBT_PUBLIC void MSG_zone_get_hosts(msg_netzone_t zone, xbt_dynar_t whereto);
/* ******************************** Hosts ************************************ */
typedef sg_host_t msg_host_t;
-#define MSG_get_host_number() sg_host_count()
-#define MSG_get_host_by_name(n) sg_host_by_name(n) /* Rewrite the old name into the new one transparently */
-
-#define MSG_hosts_as_dynar() sg_hosts_as_dynar()
-
-#define MSG_host_by_name(name) sg_host_by_name(name)
-#define MSG_host_get_name(host) sg_host_get_name(host)
-#define MSG_host_get_data(host) sg_host_user(host)
-#define MSG_host_set_data(host, data) sg_host_user_set(host, data)
-#define MSG_host_get_mounted_storage_list(host) sg_host_get_mounted_storage_list(host)
-#define MSG_host_get_attached_storage_list(host) host_get_attached_storage_list(host)
-#define MSG_host_get_speed(host) sg_host_speed(host)
-#define MSG_host_get_power_peak_at(host, pstate_index) sg_host_get_pstate_speed(host, pstate_index)
-#define MSG_host_get_core_number(host) sg_host_core_count(host)
-#define MSG_host_self() sg_host_self()
-#define MSG_host_get_nb_pstates(host) sg_host_get_nb_pstates(host)
-#define MSG_host_get_pstate(h) sg_host_get_pstate(h)
-#define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate)
-#define MSG_host_on(h) sg_host_turn_on(h)
-#define MSG_host_off(h) sg_host_turn_off(h)
-#define MSG_host_is_on(h) sg_host_is_on(h)
-#define MSG_host_is_off(h) sg_host_is_off(h)
-#define MSG_host_get_properties(host) sg_host_get_properties(host)
-#define MSG_host_get_property_value(host, name) sg_host_get_property_value(host, name)
-#define MSG_host_set_property_value(host, name, value) sg_host_set_property_value(host, name, value)
-#define MSG_host_get_process_list(host, whereto) sg_host_get_actor_list(host, whereto)
+XBT_PUBLIC size_t MSG_get_host_number();
+XBT_PUBLIC sg_host_t MSG_get_host_by_name(const char* name);
+XBT_PUBLIC sg_host_t MSG_host_by_name(const char* name);
+
+XBT_PUBLIC xbt_dynar_t MSG_hosts_as_dynar();
+
+XBT_PUBLIC const char* MSG_host_get_name(sg_host_t host);
+XBT_PUBLIC void* MSG_host_get_data(sg_host_t host);
+XBT_PUBLIC void MSG_host_set_data(sg_host_t host, void* data);
+XBT_PUBLIC xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host);
+XBT_PUBLIC xbt_dynar_t MSG_host_get_attached_storage_listsg_host_t(sg_host_t host);
+XBT_PUBLIC double MSG_host_get_speed(sg_host_t host);
+XBT_PUBLIC double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index);
+XBT_PUBLIC int MSG_host_get_core_number(sg_host_t host);
+XBT_PUBLIC int MSG_host_get_nb_pstates(sg_host_t host);
+XBT_PUBLIC int MSG_host_get_pstate(sg_host_t host);
+XBT_PUBLIC void MSG_host_set_pstate(sg_host_t host, int pstate);
+XBT_PUBLIC void MSG_host_on(sg_host_t h);
+XBT_PUBLIC void MSG_host_off(sg_host_t h);
+XBT_PUBLIC int MSG_host_is_on(sg_host_t h);
+XBT_PUBLIC int MSG_host_is_off(sg_host_t h);
+XBT_PUBLIC xbt_dict_t MSG_host_get_properties(sg_host_t host);
+XBT_PUBLIC const char* MSG_host_get_property_value(sg_host_t host, const char* name);
+XBT_PUBLIC void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value);
+XBT_PUBLIC void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto);
+
+XBT_PUBLIC sg_host_t MSG_host_self();
XBT_ATTRIB_DEPRECATED_v320("Use MSG_host_get_speed(): v3.20 will drop MSG_host_get_current_power_peak() "
"completely.") static inline double MSG_host_get_current_power_peak(msg_host_t host)
/* ******************************** VMs ************************************* */
typedef sg_vm_t msg_vm_t;
-#define MSG_vm_create_core(vm, name) sg_vm_create_core(vm, name)
-#define MSG_vm_create_multicore(vm, name, coreAmount) sg_vm_create_multicore(vm, name, coreAmount)
XBT_ATTRIB_DEPRECATED_v322("Use sg_vm_create_migratable() from the live migration plugin: "
"v3.22 will drop MSG_vm_create() completely.") XBT_PUBLIC sg_vm_t
MSG_vm_create(sg_host_t ind_pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity);
-#define MSG_vm_is_created(vm) sg_vm_is_created(vm)
-#define MSG_vm_is_running(vm) sg_vm_is_running(vm)
-#define MSG_vm_is_suspended(vm) sg_vm_is_suspended(vm)
+XBT_PUBLIC msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name);
+XBT_PUBLIC msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount);
-#define MSG_vm_get_name(vm) sg_vm_get_name(vm)
-#define MSG_vm_set_ramsize(vm, size) sg_vm_set_ramsize(vm, size)
-#define MSG_vm_get_ramsize(vm) sg_vm_get_ramsize(vm)
-#define MSG_vm_set_bound(vm, bound) sg_vm_set_bound(vm, bound)
-#define MSG_vm_get_pm(vm) sg_vm_get_pm(vm)
+XBT_PUBLIC int MSG_vm_is_created(msg_vm_t vm);
+XBT_PUBLIC int MSG_vm_is_running(msg_vm_t vm);
+XBT_PUBLIC int MSG_vm_is_suspended(msg_vm_t vm);
-#define MSG_vm_start(vm) sg_vm_start(vm)
-#define MSG_vm_suspend(vm) sg_vm_suspend(vm)
-#define MSG_vm_resume(vm) sg_vm_resume(vm)
-#define MSG_vm_shutdown(vm) sg_vm_shutdown(vm)
-#define MSG_vm_destroy(vm) sg_vm_destroy(vm)
+XBT_PUBLIC const char* MSG_vm_get_name(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_set_ramsize(msg_vm_t vm, size_t size);
+XBT_PUBLIC size_t MSG_vm_get_ramsize(msg_vm_t vm);
+XBT_PUBLIC msg_host_t MSG_vm_get_pm(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_set_bound(msg_vm_t vm, double bound);
-/* ******************************** Storage ************************************ */
+XBT_PUBLIC void MSG_vm_start(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_suspend(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_resume(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_shutdown(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_destroy(msg_vm_t vm);
+
+/* ******************************** Storage ********************************* */
typedef sg_storage_t msg_storage_t;
-#define MSG_storage_get_name(storage) sg_storage_get_name(storage)
-#define MSG_storage_get_by_name(name) sg_storage_get_by_name(name)
-#define MSG_storage_get_properties(storage) sg_storage_get_properties(storage)
-#define MSG_storage_set_property_value(storage, name, value) sg_storage_set_property_value(storage, name, value)
-#define MSG_storage_get_property_value(storage, name) sg_storage_get_property_value(storage, name)
-#define MSG_storages_as_dynar() sg_storages_as_dynar()
-#define MSG_storage_set_data(storage, data) sg_storage_set_data(storage, data)
-#define MSG_storage_get_data(storage) sg_storage_get_data(storage)
-#define MSG_storage_get_host(storage) sg_storage_get_host(storage)
-#define MSG_storage_read(storage, size) sg_storage_read(storage, size)
-#define MSG_storage_write(storage, size) sg_storage_write(storage, size)
+XBT_PUBLIC const char* MSG_storage_get_name(msg_storage_t storage);
+XBT_PUBLIC msg_storage_t MSG_storage_get_by_name(const char* name);
+XBT_PUBLIC xbt_dict_t MSG_storage_get_properties(msg_storage_t storage);
+XBT_PUBLIC void MSG_storage_set_property_value(msg_storage_t storage, const char* name, const char* value);
+XBT_PUBLIC const char* MSG_storage_get_property_value(msg_storage_t storage, const char* name);
+XBT_PUBLIC xbt_dynar_t MSG_storages_as_dynar();
+XBT_PUBLIC void MSG_storage_set_data(msg_storage_t storage, void* data);
+XBT_PUBLIC void* MSG_storage_get_data(msg_storage_t storage);
+XBT_PUBLIC const char* MSG_storage_get_host(msg_storage_t storage);
+XBT_PUBLIC sg_size_t MSG_storage_read(msg_storage_t storage, sg_size_t size);
+XBT_PUBLIC sg_size_t MSG_storage_write(msg_storage_t storage, sg_size_t size);
+
+/* ******************************** Actor/process *************************** */
+typedef sg_actor_t msg_process_t;
+
+XBT_PUBLIC int MSG_process_get_PID(msg_process_t process);
+XBT_PUBLIC int MSG_process_get_PPID(msg_process_t process);
+XBT_PUBLIC const char* MSG_process_get_name(msg_process_t process);
+XBT_PUBLIC sg_host_t MSG_process_get_host(msg_process_t process);
+
+/*property handlers*/
+XBT_PUBLIC xbt_dict_t MSG_process_get_properties(msg_process_t process);
+XBT_PUBLIC const char* MSG_process_get_property_value(msg_process_t process, const char* name);
+
+XBT_PUBLIC void MSG_process_suspend(msg_process_t process);
+XBT_PUBLIC void MSG_process_resume(msg_process_t process);
+XBT_PUBLIC int MSG_process_is_suspended(msg_process_t process);
+XBT_PUBLIC void MSG_process_restart(msg_process_t process);
+XBT_PUBLIC void MSG_process_daemonize(msg_process_t process);
/* ******************************** File ************************************ */
typedef sg_file_t msg_file_t;
*/
#define MSG_TASK_UNINITIALIZED NULL
-/* ****************************** Process *********************************** */
-
-/** @brief Process datatype.
- @ingroup m_process_management
-
- A process may be defined as a <em>code</em>, with some
- <em>private data</em>, executing in a <em>location</em>.
-
- You should not access directly to the fields of the pointed
- structure, but always use the provided API to interact with
- processes.
- */
-typedef s4u_Actor* msg_process_t;
-
/** @brief Return code of most MSG functions
@ingroup msg_simulation
@{ */
XBT_PUBLIC msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host);
XBT_PUBLIC void MSG_process_yield();
-XBT_PUBLIC void* MSG_process_get_data(msg_process_t process);
-XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
-XBT_PUBLIC msg_host_t MSG_process_get_host(msg_process_t process);
XBT_PUBLIC msg_process_t MSG_process_from_PID(int PID);
-XBT_PUBLIC int MSG_process_get_PID(msg_process_t process);
-XBT_PUBLIC int MSG_process_get_PPID(msg_process_t process);
-XBT_PUBLIC const char* MSG_process_get_name(msg_process_t process);
XBT_PUBLIC int MSG_process_self_PID();
XBT_PUBLIC int MSG_process_self_PPID();
XBT_PUBLIC const char* MSG_process_self_name();
XBT_PUBLIC msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time);
-/*property handlers*/
-XBT_PUBLIC xbt_dict_t MSG_process_get_properties(msg_process_t process);
-XBT_PUBLIC const char* MSG_process_get_property_value(msg_process_t process, const char* name);
+XBT_PUBLIC void* MSG_process_get_data(msg_process_t process);
+XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
-XBT_PUBLIC msg_error_t MSG_process_suspend(msg_process_t process);
-XBT_PUBLIC msg_error_t MSG_process_resume(msg_process_t process);
-XBT_PUBLIC int MSG_process_is_suspended(msg_process_t process);
XBT_PUBLIC void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void* data);
XBT_PUBLIC void MSG_process_auto_restart_set(msg_process_t process, int auto_restart);
-XBT_PUBLIC void MSG_process_daemonize(msg_process_t process);
-XBT_PUBLIC msg_process_t MSG_process_restart(msg_process_t process);
XBT_PUBLIC void MSG_process_ref(msg_process_t process);
XBT_PUBLIC void MSG_process_unref(msg_process_t process);
return;
}
- MSG_process_daemonize(process);
+ process->daemonize();
}
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll(JNIEnv* env, jclass cls)
return;
}
- /* try to suspend the process */
- msg_error_t rv = MSG_process_suspend(process);
-
- jxbt_check_res("MSG_process_suspend()", rv, MSG_OK, "unexpected error , please report this bug");
+ /* suspend the process */
+ process->suspend();
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject jprocess)
return;
}
- /* try to resume the process */
- msg_error_t res = MSG_process_resume(process);
- jxbt_check_res("MSG_process_resume()", res, MSG_OK, "unexpected error , please report this bug");
+ /* resume the process */
+ process->resume();
}
JNIEXPORT void
return;
}
- MSG_process_restart(process);
+ process->restart();
}
JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env, jobject jprocess)
}
/* true is the process is suspended, false otherwise */
- return (jboolean) MSG_process_is_suspended(process);
+ return (jboolean)process->isSuspended();
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
#include "src/instr/instr_private.hpp"
#include "src/msg/msg_private.hpp"
#include "src/simix/ActorImpl.hpp"
+#include <simgrid/actor.h>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process");
msg_global->process_data_cleanup = data_cleanup;
}
-msg_host_t MSG_process_get_host(msg_process_t process)
-{
- if (process == nullptr) {
- return SIMIX_process_self()->host;
- } else {
- return process->getHost();
- }
-}
-
/** \ingroup m_process_management
*
* \brief Return a #msg_process_t given its PID.
return MSG_OK;
}
-/** \ingroup m_process_management
- * \brief Returns the process ID of \a process.
- *
- * This function checks whether \a process is a valid pointer and return its PID (or 0 in case of problem).
- */
-int MSG_process_get_PID(msg_process_t process)
-{
- /* Do not raise an exception here: this function is called by the logs
- * and the exceptions, so it would be called back again and again */
- if (process == nullptr || process->getImpl() == nullptr)
- return 0;
- return process->getPid();
-}
-
-/** \ingroup m_process_management
- * \brief Returns the process ID of the parent of \a process.
- *
- * This function checks whether \a process is a valid pointer and return its PID.
- * Returns -1 if the process has not been created by any other process.
- */
-int MSG_process_get_PPID(msg_process_t process)
-{
- return process->getPpid();
-}
-
-/** \ingroup m_process_management
- * \brief Return the name of a process.
- *
- * This function checks whether \a process is a valid pointer and return its name.
- */
-const char *MSG_process_get_name(msg_process_t process)
-{
- return process->getCname();
-}
-
-/** \ingroup m_process_management
- * \brief Returns the value of a given process property
- *
- * \param process a process
- * \param name a property name
- * \return value of a property (or nullptr if the property is not set)
- */
-const char *MSG_process_get_property_value(msg_process_t process, const char *name)
-{
- return process->getProperty(name);
-}
-
-/** \ingroup m_process_management
- * \brief Return the list of properties
- *
- * This function returns all the parameters associated with a process
- */
-xbt_dict_t MSG_process_get_properties(msg_process_t process)
-{
- xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
- xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
- std::map<std::string, std::string>* props = process->getProperties();
- if (props == nullptr)
- return nullptr;
- for (auto const& elm : *props) {
- xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
- }
- return as_dict;
-}
/** \ingroup m_process_management
* \brief Return the PID of the current process.
return SIMIX_process_self()->ciface();
}
-/** \ingroup m_process_management
- * \brief Suspend the process.
- *
- * This function suspends the process by suspending the task on which it was waiting for the completion.
- */
-msg_error_t MSG_process_suspend(msg_process_t process)
-{
- xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
- process->suspend();
- return MSG_OK;
-}
-
-/** \ingroup m_process_management
- * \brief Resume a suspended process.
- *
- * This function resumes a suspended process by resuming the task on which it was waiting for the completion.
- */
-msg_error_t MSG_process_resume(msg_process_t process)
-{
- xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
- process->resume();
- return MSG_OK;
-}
-
-/** \ingroup m_process_management
- * \brief Returns true if the process is suspended .
- *
- * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
- */
-int MSG_process_is_suspended(msg_process_t process)
-{
- return process->isSuspended();
-}
-
smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
return process->getImpl()->context;
}
{
process->setAutoRestart(auto_restart);
}
-/**
- * \ingroup m_process_management
- * \brief Restarts a process from the beginning.
- */
-XBT_PUBLIC msg_process_t MSG_process_restart(msg_process_t process)
-{
- return process->restart();
-}
-
-/** @ingroup m_process_management
- * @brief This process will be terminated automatically when the last non-daemon process finishes
- */
-XBT_PUBLIC void MSG_process_daemonize(msg_process_t process)
-{
- process->daemonize();
-}
/** @ingroup m_process_management
* @brief Take an extra reference on that process to prevent it to be garbage-collected
{
vm->destroy();
}
+/* ************************** Backward ABI compatibility *************************** */
+sg_vm_t MSG_vm_create_core(sg_host_t pm, const char* name) __attribute__((alias("sg_vm_create_core")));
+sg_vm_t MSG_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount)
+ __attribute__((alias("sg_vm_create_multicore")));
+
+int MSG_vm_is_created(sg_vm_t vm) __attribute__((alias("sg_vm_is_created")));
+int MSG_vm_is_running(sg_vm_t vm) __attribute__((alias("sg_vm_is_running")));
+int MSG_vm_is_suspended(sg_vm_t vm) __attribute__((alias("sg_vm_is_suspended")));
+
+const char* MSG_vm_get_name(sg_vm_t vm) __attribute__((alias("sg_vm_get_name")));
+void MSG_vm_set_ramsize(sg_vm_t vm, size_t size) __attribute__((alias("sg_vm_set_ramsize")));
+size_t MSG_vm_get_ramsize(sg_vm_t vm) __attribute__((alias("sg_vm_get_ramsize")));
+sg_host_t MSG_vm_get_pm(sg_vm_t vm) __attribute__((alias("sg_vm_get_pm")));
+void MSG_vm_set_bound(sg_vm_t vm, double bound) __attribute__((alias("sg_vm_set_bound")));
+
+void MSG_vm_start(sg_vm_t vm) __attribute__((alias("sg_vm_start")));
+void MSG_vm_suspend(sg_vm_t vm) __attribute__((alias("sg_vm_suspend")));
+void MSG_vm_resume(sg_vm_t vm) __attribute__((alias("sg_vm_resume")));
+void MSG_vm_shutdown(sg_vm_t vm) __attribute__((alias("sg_vm_shutdown")));
+void MSG_vm_destroy(sg_vm_t vm) __attribute__((alias("sg_vm_destroy")));
+
SG_END_DECL()
{
SIMIX_process_self()->iface()->migrate(new_host);
}
+} // namespace this_actor
+} // namespace s4u
+} // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+SG_BEGIN_DECL()
+/** \ingroup m_actor_management
+ * \brief Returns the process ID of \a actor.
+ *
+ * This function checks whether \a actor is a valid pointer and return its PID (or 0 in case of problem).
+ */
+int sg_actor_get_PID(sg_actor_t actor)
+{
+ /* Do not raise an exception here: this function is called by the logs
+ * and the exceptions, so it would be called back again and again */
+ if (actor == nullptr || actor->getImpl() == nullptr)
+ return 0;
+ return actor->getPid();
+}
+
+/** \ingroup m_actor_management
+ * \brief Returns the process ID of the parent of \a actor.
+ *
+ * This function checks whether \a actor is a valid pointer and return its parent's PID.
+ * Returns -1 if the actor has not been created by any other actor.
+ */
+int sg_actor_get_PPID(sg_actor_t actor)
+{
+ return actor->getPpid();
+}
+
+/** \ingroup m_actor_management
+ * \brief Return the name of an actor.
+ */
+const char* sg_actor_get_name(sg_actor_t actor)
+{
+ return actor->getCname();
+}
+
+sg_host_t sg_actor_get_host(sg_actor_t actor)
+{
+ return actor->getHost();
+}
+
+/** \ingroup m_actor_management
+ * \brief Returns the value of a given actor property
+ *
+ * \param actor an actor
+ * \param name a property name
+ * \return value of a property (or nullptr if the property is not set)
+ */
+const char* sg_actor_get_property_value(sg_actor_t actor, const char* name)
+{
+ return actor->getProperty(name);
+}
+
+/** \ingroup m_actor_management
+ * \brief Return the list of properties
+ *
+ * This function returns all the parameters associated with an actor
+ */
+xbt_dict_t sg_actor_get_properties(sg_actor_t actor)
+{
+ xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
+ xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
+ std::map<std::string, std::string>* props = actor->getProperties();
+ if (props == nullptr)
+ return nullptr;
+ for (auto const& elm : *props) {
+ xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
+ }
+ return as_dict;
+}
+
+/** \ingroup m_actor_management
+ * \brief Suspend the actor.
+ *
+ * This function suspends the actor by suspending the task on which it was waiting for the completion.
+ */
+void sg_actor_suspend(sg_actor_t actor)
+{
+ xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
+ actor->suspend();
+}
+
+/** \ingroup m_actor_management
+ * \brief Resume a suspended actor.
+ *
+ * This function resumes a suspended actor by resuming the task on which it was waiting for the completion.
+ */
+void sg_actor_resume(sg_actor_t actor)
+{
+ xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
+ actor->resume();
}
+
+/** \ingroup m_actor_management
+ * \brief Returns true if the actor is suspended .
+ *
+ * This checks whether an actor is suspended or not by inspecting the task on which it was waiting for the completion.
+ */
+int sg_actor_is_suspended(sg_actor_t actor)
+{
+ return actor->isSuspended();
}
+
+/**
+ * \ingroup m_actor_management
+ * \brief Restarts an actor from the beginning.
+ */
+sg_actor_t sg_actor_restart(sg_actor_t actor)
+{
+ return actor->restart();
}
+
+/** @ingroup m_actor_management
+ * @brief This actor will be terminated automatically when the last non-daemon actor finishes
+ */
+void sg_actor_daemonize(sg_actor_t actor)
+{
+ actor->daemonize();
+}
+
+/* ************************** Backward ABI compatibility *************************** */
+int MSG_process_get_PID(sg_actor_t actor) __attribute__((alias("sg_actor_get_PID")));
+int MSG_process_get_PPID(sg_actor_t actor) __attribute__((alias("sg_actor_get_PPID")));
+const char* MSG_process_get_name(sg_actor_t actor) __attribute__((alias("sg_actor_get_name")));
+sg_host_t MSG_process_get_host(sg_actor_t actor) __attribute__((alias("sg_actor_get_host")));
+xbt_dict_t MSG_process_get_properties(sg_actor_t actor) __attribute__((alias("sg_actor_get_properties")));
+const char* MSG_process_get_property_value(sg_actor_t actor, const char* name)
+ __attribute__((alias("sg_actor_get_property_value")));
+void MSG_process_suspend(sg_actor_t actor) __attribute__((alias("sg_actor_suspend")));
+void MSG_process_resume(sg_actor_t actor) __attribute__((alias("sg_actor_resume")));
+int MSG_process_is_suspended(sg_actor_t actor) __attribute__((alias("sg_actor_is_suspended")));
+void MSG_process_restart(sg_actor_t actor) __attribute__((alias("sg_actor_restart")));
+void MSG_process_daemonize(sg_actor_t actor) __attribute__((alias("sg_actor_daemonize")));
+SG_END_DECL()
xbt_dynar_push(whereto, &host);
}
+/* ************************** Backward ABI compatibility *************************** */
+sg_netzone_t MSG_zone_get_root() __attribute__((alias("sg_zone_get_root")));
+;
+const char* MSG_zone_get_name(sg_netzone_t zone) __attribute__((alias("sg_zone_get_name")));
+;
+sg_netzone_t MSG_zone_get_by_name(const char* name) __attribute__((alias("sg_zone_get_by_name")));
+;
+void MSG_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto) __attribute__((alias("sg_zone_get_sons")));
+;
+const char* MSG_zone_get_property_value(sg_netzone_t zone, const char* name)
+ __attribute__((alias("sg_zone_get_property_value")));
+;
+void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, char* value)
+ __attribute__((alias("sg_zone_set_property_value")));
+;
+void MSG_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto) __attribute__((alias("sg_zone_get_hosts")));
+;
+
SG_END_DECL()
{
return storage->write(size);
}
+
+/* ************************** Backward ABI compatibility *************************** */
+const char* MSG_storage_get_name(sg_storage_t storage) __attribute__((alias("sg_storage_get_name")));
+sg_storage_t MSG_storage_get_by_name(const char* name) __attribute__((alias("sg_storage_get_by_name")));
+xbt_dict_t MSG_storage_get_properties(sg_storage_t storage) __attribute__((alias("sg_storage_get_properties")));
+void MSG_storage_set_property_value(sg_storage_t storage, const char* name, const char* value)
+ __attribute__((alias("sg_storage_set_property_value")));
+const char* MSG_storage_get_property_value(sg_storage_t storage, const char* name)
+ __attribute__((alias("sg_storage_get_property_value")));
+xbt_dynar_t MSG_storages_as_dynar() __attribute__((alias("sg_storages_as_dynar")));
+void MSG_storage_set_data(sg_storage_t storage, void* data) __attribute__((alias("sg_storage_set_data")));
+void* MSG_storage_get_data(sg_storage_t storage) __attribute__((alias("sg_storage_get_data")));
+const char* MSG_storage_get_host(sg_storage_t storage) __attribute__((alias("sg_storage_get_host")));
+sg_size_t MSG_storage_read(sg_storage_t storage, sg_size_t size) __attribute__((alias("sg_storage_read")));
+sg_size_t MSG_storage_write(sg_storage_t storage, sg_size_t size) __attribute__((alias("sg_storage_write")));
+
SG_END_DECL()
}
}
+sg_host_t sg_host_self()
+{
+ smx_actor_t process = SIMIX_process_self();
+ return (process == nullptr) ? nullptr : process->host;
+}
+
+/* ************************** Backward ABI compatibility *************************** */
+xbt_dynar_t MSG_hosts_as_dynar() __attribute__((alias("sg_hosts_as_dynar")));
+
+size_t MSG_get_host_number() __attribute__((alias("sg_host_count")));
+sg_host_t MSG_get_host_by_name(const char* name) __attribute__((alias("sg_host_by_name")));
+sg_host_t MSG_host_by_name(const char* name) __attribute__((alias("sg_host_by_name")));
+
+const char* MSG_host_get_name(sg_host_t host) __attribute__((alias("sg_host_get_name")));
+void* MSG_host_get_data(sg_host_t host) __attribute__((alias("sg_host_user")));
+void MSG_host_set_data(sg_host_t host, void* data) __attribute__((alias("sg_host_user_set")));
+xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host) __attribute__((alias("sg_host_get_mounted_storage_list")));
+xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host)
+ __attribute__((alias("sg_host_get_attached_storage_list")));
+double MSG_host_get_speed(sg_host_t host) __attribute__((alias("sg_host_speed")));
+double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index) __attribute__((alias("sg_host_get_pstate_speed")));
+int MSG_host_get_core_number(sg_host_t host) __attribute__((alias("sg_host_core_count")));
+int MSG_host_get_nb_pstates(sg_host_t host) __attribute__((alias("sg_host_get_nb_pstates")));
+int MSG_host_get_pstate(sg_host_t host) __attribute__((alias("sg_host_get_pstate")));
+void MSG_host_set_pstate(sg_host_t host, int pstate) __attribute__((alias("sg_host_set_pstate")));
+void MSG_host_on(sg_host_t h) __attribute__((alias("sg_host_turn_on")));
+void MSG_host_off(sg_host_t h) __attribute__((alias("sg_host_turn_off")));
+int MSG_host_is_on(sg_host_t h) __attribute__((alias("sg_host_is_on")));
+int MSG_host_is_off(sg_host_t h) __attribute__((alias("sg_host_is_off")));
+xbt_dict_t MSG_host_get_properties(sg_host_t host) __attribute__((alias("sg_host_get_properties")));
+const char* MSG_host_get_property_value(sg_host_t host, const char* name)
+ __attribute__((alias("sg_host_get_property_value")));
+void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value)
+ __attribute__((alias("sg_host_set_property_value")));
+void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto) __attribute__((alias("sg_host_get_actor_list")));
+sg_host_t MSG_host_self() __attribute__((alias("sg_host_self")));
+
} // extern "C"
}
}
-sg_host_t sg_host_self()
-{
- smx_actor_t process = SIMIX_process_self();
- return (process == nullptr) ? nullptr : process->host;
-}
-
/* needs to be public and without simcall for exceptions and logging events */
const char* sg_host_self_get_name()
{
set(headers_to_install
+ include/simgrid/actor.h
include/simgrid/chrono.hpp
include/simgrid/plugins/dvfs.h
include/simgrid/plugins/energy.h