One day, all msg_blah_t will point to s4u::Blah*.
(I'm glad it worked: that's the second time I attempt this improvement!)
Other changes on the way:
- change the prototype of MSG_host_get_process_list():
it was returning the internal list, but this one contains smx_actor_t,
not msg_process_t as we can handle from the public interface
- convert a C test in teshsuite to C++ (even if I could have avoided this)
15 files changed:
structure, but always use the provided API to interact with
processes.
*/
structure, but always use the provided API to interact with
processes.
*/
-typedef smx_actor_t msg_process_t;
+typedef s4u_Actor* msg_process_t;
/** @brief Return code of most MSG functions
@ingroup msg_simulation
/** @brief Return code of most MSG functions
@ingroup msg_simulation
XBT_PUBLIC(msg_host_t) MSG_host_self();
XBT_PUBLIC(double) MSG_host_get_speed(msg_host_t h);
XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h);
XBT_PUBLIC(msg_host_t) MSG_host_self();
XBT_PUBLIC(double) MSG_host_get_speed(msg_host_t h);
XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h);
-XBT_PUBLIC(xbt_swag_t) MSG_host_get_process_list(msg_host_t h);
+XBT_PUBLIC(void) MSG_host_get_process_list(msg_host_t h, xbt_dynar_t whereto);
XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h);
XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h);
XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
/** Ask kindly to all actors to die. Only the issuer will survive. */
static void killAll();
/** Ask kindly to all actors to die. Only the issuer will survive. */
static void killAll();
/** Returns the internal implementation of this actor */
simix::ActorImpl* getImpl();
};
/** Returns the internal implementation of this actor */
simix::ActorImpl* getImpl();
};
-typedef simgrid::kernel::context::Context *smx_context_t;
-typedef simgrid::simix::ActorImpl *smx_actor_t;
-typedef simgrid::simix::Mutex *smx_mutex_t;
+typedef simgrid::kernel::context::Context* smx_context_t;
+typedef simgrid::simix::ActorImpl* smx_actor_t;
+typedef simgrid::simix::Mutex* smx_mutex_t;
typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t;
#else
typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t;
#else
JNIEnv *env = get_current_thread_env();
simgrid::kernel::context::JavaContext* context = static_cast<simgrid::kernel::context::JavaContext*>(SIMIX_context_self());
context->jprocess = jprocess;
JNIEnv *env = get_current_thread_env();
simgrid::kernel::context::JavaContext* context = static_cast<simgrid::kernel::context::JavaContext*>(SIMIX_context_self());
context->jprocess = jprocess;
- smx_actor_t process = SIMIX_process_self();
+ msg_process_t process = MSG_process_self();
jprocess_bind(context->jprocess, process, env);
// Adrien, ugly path, just to bypass creation of context at low levels (i.e such as for the VM migration for instance)
jprocess_bind(context->jprocess, process, env);
// Adrien, ugly path, just to bypass creation of context at low levels (i.e such as for the VM migration for instance)
/* Actually build the MSG process */
process = MSG_process_create_with_environment(name, [](int argc, char** argv) -> int {
/* Actually build the MSG process */
process = MSG_process_create_with_environment(name, [](int argc, char** argv) -> int {
- smx_actor_t process = SIMIX_process_self();
+ msg_process_t process = MSG_process_self();
// This is the jprocess passed as environment.
// It would be simpler if we could use a closure.
jobject jprocess = (jobject) MSG_process_get_data(process);
// This is the jprocess passed as environment.
// It would be simpler if we could use a closure.
jobject jprocess = (jobject) MSG_process_get_data(process);
char *instr_process_id (msg_process_t proc, char *str, int len)
{
char *instr_process_id (msg_process_t proc, char *str, int len)
{
- return instr_process_id_2 (proc->name.c_str(), proc->pid, str, len);//MSG_process_get_name(proc), MSG_process_get_PID(proc), str, len);
+ return instr_process_id_2 (proc->cname(), proc->pid(), str, len);
}
char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len)
}
char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len)
{
if (TRACE_msg_process_is_enabled() && status==SMX_EXIT_FAILURE){
//kill means that this process no longer exists, let's destroy it
{
if (TRACE_msg_process_is_enabled() && status==SMX_EXIT_FAILURE){
//kill means that this process no longer exists, let's destroy it
- TRACE_msg_process_destroy(process->name.c_str(), process->pid);
+ TRACE_msg_process_destroy(process->cname(), process->pid());
/* Try to receive it by calling SIMIX network layer */
try {
/* Try to receive it by calling SIMIX network layer */
try {
- simcall_comm_recv(MSG_process_self(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
+ simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
(*task)->simdata->setNotUsed();
}
XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
(*task)->simdata->setNotUsed();
}
void *match_data, void_f_pvoid_t cleanup, int detached)
{
simdata_task_t t_simdata = nullptr;
void *match_data, void_f_pvoid_t cleanup, int detached)
{
simdata_task_t t_simdata = nullptr;
- msg_process_t myself = SIMIX_process_self();
+ msg_process_t myself = MSG_process_self();
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(alias);
int call_end = TRACE_msg_task_put_start(task);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(alias);
int call_end = TRACE_msg_task_put_start(task);
msg_global->sent_msg++;
/* Send it by calling SIMIX network layer */
msg_global->sent_msg++;
/* Send it by calling SIMIX network layer */
- smx_activity_t act = simcall_comm_isend(myself, mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate,
+ smx_activity_t act = simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate,
task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached);
t_simdata->comm = static_cast<simgrid::kernel::activity::Comm*>(act);
task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached);
t_simdata->comm = static_cast<simgrid::kernel::activity::Comm*>(act);
comm->task_sent = nullptr;
comm->task_received = task;
comm->status = MSG_OK;
comm->task_sent = nullptr;
comm->task_received = task;
comm->status = MSG_OK;
- comm->s_comm = simcall_comm_irecv(MSG_process_self(), mbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, rate);
+ comm->s_comm = simcall_comm_irecv(SIMIX_process_self(), mbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, rate);
// notify the user callback if any
if (msg_global->task_copy_callback) {
msg_task_t task = static_cast<msg_task_t>(buff);
// notify the user callback if any
if (msg_global->task_copy_callback) {
msg_task_t task = static_cast<msg_task_t>(buff);
- msg_global->task_copy_callback(task, comm->src_proc, comm->dst_proc);
+ msg_global->task_copy_callback(task, comm->src_proc->ciface(), comm->dst_proc->ciface());
#include "simgrid/s4u/host.hpp"
#include "simgrid/s4u/storage.hpp"
#include "src/msg/msg_private.h"
#include "simgrid/s4u/host.hpp"
#include "simgrid/s4u/storage.hpp"
#include "src/msg/msg_private.h"
+#include "src/simix/ActorImpl.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg);
* \brief Return the list of processes attached to an host.
*
* \param host a host
* \brief Return the list of processes attached to an host.
*
* \param host a host
- * \return a swag with the attached processes
+ * \param whereto a dynar in which we should push processes living on that host
-xbt_swag_t MSG_host_get_process_list(msg_host_t host)
+void MSG_host_get_process_list(msg_host_t host, xbt_dynar_t whereto)
{
xbt_assert((host != nullptr), "Invalid parameters");
{
xbt_assert((host != nullptr), "Invalid parameters");
- return host->processes();
+ smx_actor_t actor = NULL;
+ xbt_swag_foreach(actor, host->processes()) {
+ msg_process_t p = actor->ciface();
+ xbt_dynar_push(whereto, &p);
+ }
}
/** \ingroup m_host_management
}
/** \ingroup m_host_management
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2004-2017. 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. */
/* 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. */
xbt_dict_t properties, smx_actor_t parent_process)
{
msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
xbt_dict_t properties, smx_actor_t parent_process)
{
msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
+ return p ? p->getImpl() : nullptr;
}
/** \ingroup m_process_management
}
/** \ingroup m_process_management
xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
simgrid::MsgActorExt* msgExt = new simgrid::MsgActorExt(data);
xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
simgrid::MsgActorExt* msgExt = new simgrid::MsgActorExt(data);
- msg_process_t process = simcall_process_create(name, std::move(code), msgExt, host, properties);
+ smx_actor_t process = simcall_process_create(name, std::move(code), msgExt, host, properties);
if (!process) { /* Undo everything */
delete msgExt;
if (!process) { /* Undo everything */
delete msgExt;
}
simcall_process_on_exit(process, (int_f_pvoid_pvoid_t)TRACE_msg_process_kill, process);
}
simcall_process_on_exit(process, (int_f_pvoid_pvoid_t)TRACE_msg_process_kill, process);
+ return process->ciface();
xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
- msg_process_t process =
- SIMIX_process_attach(name, new simgrid::MsgActorExt(data), host->cname(), properties, nullptr);
+ smx_actor_t process = SIMIX_process_attach(name, new simgrid::MsgActorExt(data), 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);
+ return process->ciface();
}
/** Detach a process attached with `MSG_process_attach()`
}
/** Detach a process attached with `MSG_process_attach()`
*/
void MSG_process_kill(msg_process_t process)
{
*/
void MSG_process_kill(msg_process_t process)
{
- simcall_process_kill(process);
+ simcall_process_kill(process->getImpl());
* \param timeout wait until the process is over, or the timeout occurs
*/
msg_error_t MSG_process_join(msg_process_t process, double timeout){
* \param timeout wait until the process is over, or the timeout occurs
*/
msg_error_t MSG_process_join(msg_process_t process, double timeout){
- simcall_process_join(process, timeout);
+ simcall_process_join(process->getImpl(), timeout);
msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
{
TRACE_msg_process_change_host(process, MSG_process_get_host(process), host);
msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
{
TRACE_msg_process_change_host(process, MSG_process_get_host(process), host);
- simcall_process_set_host(process, host);
+ simcall_process_set_host(process->getImpl(), host);
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
/* get from SIMIX the MSG process data, and then the user data */
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
/* get from SIMIX the MSG process data, and then the user data */
- simgrid::MsgActorExt* msgExt = (simgrid::MsgActorExt*)process->data;
+ simgrid::MsgActorExt* msgExt = (simgrid::MsgActorExt*)process->getImpl()->data;
if (msgExt)
return msgExt->data;
else
if (msgExt)
return msgExt->data;
else
{
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
{
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
- static_cast<simgrid::MsgActorExt*>(process->data)->data = data;
+ static_cast<simgrid::MsgActorExt*>(process->getImpl()->data)->data = data;
msg_host_t MSG_process_get_host(msg_process_t process)
{
if (process == nullptr) {
msg_host_t MSG_process_get_host(msg_process_t process)
{
if (process == nullptr) {
- return MSG_process_self()->host;
+ return SIMIX_process_self()->host;
+ return process->getImpl()->host;
*/
msg_process_t MSG_process_from_PID(int PID)
{
*/
msg_process_t MSG_process_from_PID(int PID)
{
- return SIMIX_process_from_PID(PID);
+ return SIMIX_process_from_PID(PID)->ciface();
}
/** @brief returns a list of all currently existing processes */
}
/** @brief returns a list of all currently existing processes */
*/
msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time)
{
*/
msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time)
{
- simcall_process_set_kill_time(process,kill_time);
+ simcall_process_set_kill_time(process->getImpl(), kill_time);
{
/* 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 */
- if (process == nullptr)
+ if (process == nullptr || process->getImpl() == nullptr)
+ return process->getImpl()->pid;
}
/** \ingroup m_process_management
}
/** \ingroup m_process_management
*/
int MSG_process_get_PPID(msg_process_t process)
{
*/
int MSG_process_get_PPID(msg_process_t process)
{
+ return process->getImpl()->ppid;
}
/** \ingroup m_process_management
}
/** \ingroup m_process_management
*/
const char *MSG_process_get_name(msg_process_t process)
{
*/
const char *MSG_process_get_name(msg_process_t process)
{
- return process->name.c_str();
+ return process->cname();
}
/** \ingroup m_process_management
}
/** \ingroup m_process_management
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 MSG_process_get_properties(msg_process_t process)
{
xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
- return simcall_process_get_properties(process);
+ return simcall_process_get_properties(process->getImpl());
}
/** \ingroup m_process_management
}
/** \ingroup m_process_management
*/
int MSG_process_self_PID()
{
*/
int MSG_process_self_PID()
{
- return MSG_process_get_PID(MSG_process_self());
+ smx_actor_t self = SIMIX_process_self();
+ return self == nullptr ? 0 : self->pid;
}
/** \ingroup m_process_management
}
/** \ingroup m_process_management
*/
msg_process_t MSG_process_self()
{
*/
msg_process_t MSG_process_self()
{
- return SIMIX_process_self();
+ return SIMIX_process_self()->ciface();
}
/** \ingroup m_process_management
}
/** \ingroup m_process_management
xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
TRACE_msg_process_suspend(process);
xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
TRACE_msg_process_suspend(process);
- simcall_process_suspend(process);
+ simcall_process_suspend(process->getImpl());
xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
TRACE_msg_process_resume(process);
xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
TRACE_msg_process_resume(process);
- simcall_process_resume(process);
+ simcall_process_resume(process->getImpl());
*/
int MSG_process_is_suspended(msg_process_t process)
{
*/
int MSG_process_is_suspended(msg_process_t process)
{
- xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
- return simcall_process_is_suspended(process);
+ return simcall_process_is_suspended(process->getImpl());
}
smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
}
smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
- return SIMIX_process_get_context(process);
+ return SIMIX_process_get_context(process->getImpl());
}
/**
* \ingroup m_process_management
}
/**
* \ingroup m_process_management
* You should use them to free the data used by your process.
*/
void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data) {
* You should use them to free the data used by your process.
*/
void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data) {
- simcall_process_on_exit(MSG_process_self(),fun,data);
+ simcall_process_on_exit(SIMIX_process_self(), fun, data);
}
/**
* \ingroup m_process_management
}
/**
* \ingroup m_process_management
* If the flag is set to 1, the process will be automatically restarted when its host comes back up.
*/
XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_restart) {
* If the flag is set to 1, the process will be automatically restarted when its host comes back up.
*/
XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_restart) {
- simcall_process_auto_restart_set(process,auto_restart);
+ simcall_process_auto_restart_set(process->getImpl(), 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) {
}
/**
* \ingroup m_process_management
* \brief Restarts a process from the beginning.
*/
XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process) {
- return simcall_process_restart(process);
+ return simcall_process_restart(process->getImpl())->ciface();
}
/** @ingroup m_process_management
}
/** @ingroup m_process_management
XBT_PUBLIC(void) MSG_process_daemonize(msg_process_t process)
{
simgrid::simix::kernelImmediate([process]() {
XBT_PUBLIC(void) MSG_process_daemonize(msg_process_t process)
{
simgrid::simix::kernelImmediate([process]() {
+ process->getImpl()->daemonize();
}
void Actor::kill(int pid) {
}
void Actor::kill(int pid) {
- msg_process_t process = SIMIX_process_from_PID(pid);
+ smx_actor_t process = SIMIX_process_from_PID(pid);
if(process != nullptr) {
simcall_process_kill(process);
} else {
if(process != nullptr) {
simcall_process_kill(process);
} else {
~ActorImpl();
simgrid::s4u::ActorPtr iface() { return s4u::ActorPtr(&piface_); }
~ActorImpl();
simgrid::s4u::ActorPtr iface() { return s4u::ActorPtr(&piface_); }
+ simgrid::s4u::Actor* ciface() { return &piface_; }
void daemonize();
bool isDaemon();
void daemonize();
bool isDaemon();
foreach(x concurrent_rw get_sender host_on_off host_on_off_recv host_on_off_processes host_on_off_wait listen_async pid
foreach(x concurrent_rw get_sender host_on_off host_on_off_recv host_on_off_processes host_on_off_wait listen_async pid
- process storage_client_server trace_integration)
+ storage_client_server trace_integration)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
endforeach()
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
endforeach()
-foreach(x task_destroy_cancel)
+# CPP examples
+foreach(x process task_destroy_cancel)
add_executable (${x} ${x}/${x}.cpp)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
add_executable (${x} ${x}/${x}.cpp)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
MSG_task_destroy(task);
MSG_host_on(jupiter);
MSG_task_destroy(task);
MSG_host_on(jupiter);
- xbt_swag_t jupi_processes = MSG_host_get_process_list(jupiter);
- void *process;
- xbt_swag_foreach(process, jupi_processes) {
+
+ xbt_dynar_t jupi_processes = xbt_dynar_new(sizeof(msg_process_t), NULL);
+ MSG_host_get_process_list(jupiter, jupi_processes);
+ msg_process_t process = NULL;
+ unsigned int cursor;
+ xbt_dynar_foreach (jupi_processes, cursor, process) {
MSG_process_kill(process);
}
MSG_process_kill(process);
}
+ xbt_dynar_free(&jupi_processes);
task = MSG_task_create("task on without proc", task_comp_size, task_comm_size, NULL);
XBT_INFO("Sending \"%s\"", task->name);
task = MSG_task_create("task on without proc", task_comp_size, task_comm_size, NULL);
XBT_INFO("Sending \"%s\"", task->name);
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
+ xbt_assert(argc >= 2, "Usage: pid platform pid_to_kill");
+
MSG_process_killall(atoi(argv[2]));
MSG_create_environment(argv[1]);
MSG_process_killall(atoi(argv[2]));
MSG_create_environment(argv[1]);
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2017. 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. */
/* 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-static int slave(int argc, char *argv[])
+static int slave(int argc, char* argv[])
{
MSG_process_sleep(.5);
XBT_INFO("Slave started (PID:%d, PPID:%d)", MSG_process_self_PID(), MSG_process_self_PPID());
{
MSG_process_sleep(.5);
XBT_INFO("Slave started (PID:%d, PPID:%d)", MSG_process_self_PID(), MSG_process_self_PPID());
XBT_INFO("Plop i am %ssuspended", (MSG_process_is_suspended(MSG_process_self())) ? "" : "not ");
MSG_process_sleep(1);
}
XBT_INFO("Plop i am %ssuspended", (MSG_process_is_suspended(MSG_process_self())) ? "" : "not ");
MSG_process_sleep(1);
}
-static int master(int argc, char *argv[])
+static int master(int argc, char* argv[])
- xbt_swag_t process_list = MSG_host_get_process_list(MSG_host_self());
- msg_process_t process = NULL;
- xbt_swag_foreach(process, process_list) {
+ xbt_dynar_t process_list = xbt_dynar_new(sizeof(msg_process_t), nullptr);
+ MSG_host_get_process_list(MSG_host_self(), process_list);
+
+ msg_process_t process = NULL;
+ unsigned int cursor;
+ xbt_dynar_foreach (process_list, cursor, process) {
XBT_INFO("Process(pid=%d, ppid=%d, name=%s)", MSG_process_get_PID(process), MSG_process_get_PPID(process),
MSG_process_get_name(process));
if (MSG_process_self_PID() != MSG_process_get_PID(process))
MSG_process_kill(process);
}
XBT_INFO("Process(pid=%d, ppid=%d, name=%s)", MSG_process_get_PID(process), MSG_process_get_PPID(process),
MSG_process_get_name(process));
if (MSG_process_self_PID() != MSG_process_get_PID(process))
MSG_process_kill(process);
}
+ xbt_dynar_free(&process_list);
+
process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
MSG_process_sleep(2);
process = MSG_process_create("slave from master", slave, NULL, MSG_host_self());
MSG_process_sleep(2);
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
MSG_init(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\t Example: %s msg_platform.xml\n", argv[0], argv[0]);
MSG_init(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\t Example: %s msg_platform.xml\n", argv[0], argv[0]);
MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("Tremblay"));
MSG_process_create("master", master, NULL, MSG_get_host_by_name("Tremblay"));
MSG_process_create("slave", slave, NULL, MSG_get_host_by_name("Tremblay"));
+ msg_error_t res = MSG_main();
XBT_INFO("Simulation time %g", MSG_get_clock());
XBT_INFO("Simulation time %g", MSG_get_clock());