/* 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. */
/* 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. */
if (smx_proc == SIMIX_process_self()) {
/* avoid a SIMIX request if this function is called by the process itself */
msg_proc = (simdata_process_t) SIMIX_process_self_get_data();
if (smx_proc == SIMIX_process_self()) {
/* avoid a SIMIX request if this function is called by the process itself */
msg_proc = (simdata_process_t) SIMIX_process_self_get_data();
- msg_proc = (simdata_process_t) simcall_process_get_data(smx_proc);
- simcall_process_set_data(smx_proc, NULL);
+ msg_proc = (simdata_process_t)smx_proc->data;
+ simcall_process_set_data(smx_proc, nullptr);
-smx_process_t MSG_process_create_from_SIMIX(
- const char *name, std::function<void()> code, void *data, const char *hostname,
+smx_actor_t MSG_process_create_from_SIMIX(
+ const char *name, std::function<void()> code, void *data, sg_host_t host,
- msg_host_t host = MSG_host_by_name(hostname);
- msg_process_t p = MSG_process_create_with_environment(
- name, std::move(code), data, host, properties);
+ msg_process_t p = MSG_process_create_with_environment(name, std::move(code), data, host, properties);
if (p) {
MSG_process_set_kill_time(p,kill_time);
MSG_process_auto_restart_set(p,auto_restart);
if (p) {
MSG_process_set_kill_time(p,kill_time);
MSG_process_auto_restart_set(p,auto_restart);
*/
msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
{
*/
msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
{
- return MSG_process_create_with_environment(name, code, data, host, 0, NULL, NULL);
+ return MSG_process_create_with_environment(name, code, data, host, 0, nullptr, nullptr);
* A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and
* the corresponding thread) is created, and put in the list of ready process.
* A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and
* the corresponding thread) is created, and put in the list of ready process.
* \param code is a function describing the behavior of the process. It should then only use functions described
* in \ref m_process_management (to create a new #msg_process_t for example),
in \ref m_host_management (only the read-only functions i.e. whose name contains the word get),
in \ref m_task_management (to create or destroy some #msg_task_t for example) and
in \ref msg_task_usage (to handle file transfers and task processing).
* \param data a pointer to any data one may want to attach to the new object. It is for user-level information and
* \param code is a function describing the behavior of the process. It should then only use functions described
* in \ref m_process_management (to create a new #msg_process_t for example),
in \ref m_host_management (only the read-only functions i.e. whose name contains the word get),
in \ref m_task_management (to create or destroy some #msg_task_t for example) and
in \ref msg_task_usage (to handle file transfers and task processing).
* \param data a pointer to any data one may want to attach to the new object. It is for user-level information and
* \param host the location where the new process is executed.
* \param argc first argument passed to \a code
* \param argv second argument passed to \a code
* \param host the location where the new process is executed.
* \param argc first argument passed to \a code
* \param argv second argument passed to \a code
msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
int argc, char **argv)
{
msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
int argc, char **argv)
{
- return MSG_process_create_with_environment(name, code, data, host, argc, argv, NULL);
+ return MSG_process_create_with_environment(name, code, data, host, argc, argv, nullptr);
* A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and
* the corresponding thread) is created, and put in the list of ready process.
* A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and
* the corresponding thread) is created, and put in the list of ready process.
* \param code is a function describing the behavior of the process. It should then only use functions described
* in \ref m_process_management (to create a new #msg_process_t for example),
in \ref m_host_management (only the read-only functions i.e. whose name contains the word get),
in \ref m_task_management (to create or destroy some #msg_task_t for example) and
in \ref msg_task_usage (to handle file transfers and task processing).
* \param data a pointer to any data one may want to attach to the new object. It is for user-level information and
* \param code is a function describing the behavior of the process. It should then only use functions described
* in \ref m_process_management (to create a new #msg_process_t for example),
in \ref m_host_management (only the read-only functions i.e. whose name contains the word get),
in \ref m_task_management (to create or destroy some #msg_task_t for example) and
in \ref msg_task_usage (to handle file transfers and task processing).
* \param data a pointer to any data one may want to attach to the new object. It is for user-level information and
* \param host the location where the new process is executed.
* \param argc first argument passed to \a code
* \param argv second argument passed to \a code. WARNING, these strings are freed by the SimGrid kernel when the
* \param host the location where the new process is executed.
* \param argc first argument passed to \a code
* \param argv second argument passed to \a code. WARNING, these strings are freed by the SimGrid kernel when the
msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
int argc, char **argv, xbt_dict_t properties)
{
msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
int argc, char **argv, xbt_dict_t properties)
{
- simgrid::simix::wrap_main(code, argc, argv), data, host,
- properties);
+ std::move(function), data, host, properties);
const char *name, std::function<void()> code, void *data,
msg_host_t host, xbt_dict_t properties)
{
const char *name, std::function<void()> code, void *data,
msg_host_t host, xbt_dict_t properties)
{
simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
msg_process_t process;
/* Simulator data for MSG */
simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
msg_process_t process;
/* Simulator data for MSG */
/* Let's create the process: SIMIX may decide to start it right now,
* even before returning the flow control to us */
process = simcall_process_create(
/* Let's create the process: SIMIX may decide to start it right now,
* even before returning the flow control to us */
process = simcall_process_create(
- name, std::move(code), simdata, sg_host_get_name(host), -1, properties, 0);
+ name, std::move(code), simdata, host, -1, properties, 0);
*/
msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties)
{
*/
msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties)
{
simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
msg_process_t process;
/* Simulator data for MSG */
simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
msg_process_t process;
/* Simulator data for MSG */
simdata->m_host = host;
simdata->data = data;
simdata->last_errno = MSG_OK;
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
simdata->m_host = host;
simdata->data = data;
simdata->last_errno = MSG_OK;
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
- process = SIMIX_process_attach(name, simdata, sg_host_get_name(host), properties, NULL);
+ process = SIMIX_process_attach(name, simdata, host->cname(), properties, nullptr);
if (!process)
xbt_die("Could not attach");
simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
if (!process)
xbt_die("Could not attach");
simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
* Used in the main thread, it waits for the simulation to finish before returning. When it returns, the other
* simulated processes and the maestro are destroyed.
*/
* Used in the main thread, it waits for the simulation to finish before returning. When it returns, the other
* simulated processes and the maestro are destroyed.
*/
-// /* FIXME: why do we only cancel communication actions? is this useful? */
-// simdata_process_t p_simdata = simcall_process_get_data(process);
-// if (p_simdata->waiting_task && p_simdata->waiting_task->simdata->comm) {
-// simcall_comm_cancel(p_simdata->waiting_task->simdata->comm);
-// }
simdata->m_host = host;
msg_host_t now = simdata->m_host;
TRACE_msg_process_change_host(process, now, host);
simdata->m_host = host;
msg_host_t now = simdata->m_host;
TRACE_msg_process_change_host(process, now, host);
/** \ingroup m_process_management
* \brief Sets a cleanup function to be called to free the userdata of a process when a process is destroyed.
/** \ingroup m_process_management
* \brief Sets a cleanup function to be called to free the userdata of a process when a process is destroyed.
*/
XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) {
msg_global->process_data_cleanup = data_cleanup;
*/
XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) {
msg_global->process_data_cleanup = data_cleanup;
* \return the msg_host_t corresponding to the location on which \a process is running.
*/
msg_host_t MSG_process_get_host(msg_process_t process)
{
simdata_process_t simdata;
* \return the msg_host_t corresponding to the location on which \a process is running.
*/
msg_host_t MSG_process_get_host(msg_process_t process)
{
simdata_process_t simdata;
* \brief Return a #msg_process_t given its PID.
*
* This function search in the list of all the created msg_process_t for a msg_process_t whose PID is equal to \a PID.
* \brief Return a #msg_process_t given its PID.
*
* This function search in the list of all the created msg_process_t for a msg_process_t whose PID is equal to \a PID.
Note that the PID are uniq in the whole simulation, not only on a given host.
*/
msg_process_t MSG_process_from_PID(int PID)
Note that the PID are uniq in the whole simulation, not only on a given host.
*/
msg_process_t MSG_process_from_PID(int PID)
{
/* 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 */
{
/* 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 */