examples/msg/irc_isend/peer
examples/msg/irc_isend/toto.txt
examples/msg/ns3/ns3
+examples/s4u/dumb/s4u_test
examples/simdag/sd_avail
examples/simdag/ex_sd_seq_access
examples/simdag/sd_seq_access
ADD_TEST(msg-icomms-waitany ${CMAKE_BINARY_DIR}/examples/msg/icomms/peer3 ${CMAKE_HOME_DIRECTORY}/examples/platforms/small_platform.xml ${CMAKE_HOME_DIRECTORY}/examples/msg/icomms/deployment_peer05.xml)
# END TESH TESTS
+ ### S4U ###
+ ADD_TESH_FACTORIES(s4u-dumb "thread;ucontext;raw;boost" --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/dumb s4u_test.tesh)
### SIMDAG ###
# BEGIN TESH TESTS
src/simix/smx_context_boost.cpp)
endif()
+set(S4U_SRC
+ src/s4u/s4u_channel.cpp
+ src/s4u/s4u_engine.cpp
+ src/s4u/s4u_host.cpp
+ src/s4u/s4u_process.cpp
+)
+
set(SIMGRID_SRC
src/simgrid/sg_config.c
src/simgrid/host.cpp
include/simgrid/simix.h
include/simgrid/host.h
include/simgrid/link.h
+ include/simgrid/s4u/channel.hpp
+ include/simgrid/s4u/engine.hpp
+ include/simgrid/s4u/host.hpp
+ include/simgrid/s4u/process.hpp
+ include/simgrid/s4u.h
include/smpi/mpi.h
include/smpi/smpi.h
include/smpi/smpi_cocci.h
### Simgrid Lib sources
set(simgrid_sources
${BINDINGS_SRC}
+ ${S4U_SRC}
${MSG_SRC}
${SIMDAG_SRC}
${SIMGRID_SRC}
examples/msg/suspend/CMakeLists.txt
examples/msg/token_ring/CMakeLists.txt
examples/msg/tracing/CMakeLists.txt
+ examples/s4u/CMakeLists.txt
+ examples/s4u/dumb/CMakeLists.txt
examples/scala/CMakeLists.txt
examples/scala/master_slave_bypass/CMakeLists.txt
examples/scala/master_slave_kill/CMakeLists.txt
${MC_SRC}
${MC_SIMGRID_MC_SRC}
${MSG_SRC}
+ ${S4U_SRC}
${NS3_SRC}
${RNGSTREAM_SRC}
${SIMDAG_SRC}
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/s4u)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/s4u/dumb)
+
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/scala)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/scala/master_slave_bypass)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/scala/master_slave_kill)
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(tesh_files
+ ${tesh_files}
+ PARENT_SCOPE
+ )
+set(xml_files
+ ${xml_files}
+ PARENT_SCOPE
+ )
+set(examples_src
+ ${examples_src}
+ PARENT_SCOPE
+ )
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
+set(txt_files
+ ${txt_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/README
+ PARENT_SCOPE
+ )
--- /dev/null
+S4U (Simgrid for you) is the next interface of SimGrid, expected to be
+released with SimGrid 4.0.
+
+Even if it's in a very preliminary state so far, you are welcome to
+try it an report any interface glitches that you see. Be however
+warned that the interface will be modified until its final release.
+You will have to adapt your code on the way.
\ No newline at end of file
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+add_executable(s4u_test s4u_test.cpp)
+
+### Add definitions for compile
+target_link_libraries(s4u_test simgrid)
+
+set(tesh_files
+ ${tesh_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/s4u_test.tesh
+ PARENT_SCOPE
+ )
+set(xml_files
+ ${xml_files}
+ PARENT_SCOPE
+ )
+set(examples_src
+ ${examples_src}
+ ${CMAKE_CURRENT_SOURCE_DIR}/s4u_test.cpp
+ PARENT_SCOPE
+ )
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
+set(txt_files
+ ${txt_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+/* Copyright (c) 2006-2015. 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/s4u.h"
+
+using namespace simgrid;
+using namespace s4u;
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
+
+class Worker : Process {
+public:
+ Worker(const char*procname, Host *host,int argc, char **argv)
+ : s4u::Process(procname,host,argc,argv){}
+
+ int main(int argc, char **argv) {
+ XBT_INFO("Hello s4u, I'm ready to serve");
+
+ char *msg = recvstr(*Channel::byName("worker"));
+ XBT_INFO("I received '%s'",msg);
+ XBT_INFO("I'm done. See you.");
+ return 1;
+ }
+};
+
+class Master : Process {
+public:
+ Master(const char*procname, Host *host,int argc, char **argv)
+ : Process(procname,host,argc,argv){}
+
+ int main(int argc, char **argv) {
+ XBT_INFO("Hello s4u, I have something to send");
+ sendstr(*Channel::byName("worker"),"GaBuZoMeu");
+
+ XBT_INFO("I'm done. See you.");
+ return 1;
+ }
+};
+
+
+int main(int argc, char **argv) {
+ Engine *e = new Engine(&argc,argv);
+ e->loadPlatform("../../platforms/two_hosts_platform.xml");
+
+ new Worker("worker", Host::byName("host0"), 0, NULL);
+ new Master("master", Host::byName("host1"), 0, NULL);
+ e->run();
+ return 0;
+}
--- /dev/null
+#! ./tesh
+
+$ $SG_TEST_EXENV ./s4u_test
+> [host0:worker:(0) 0.000000] [s4u_test/INFO] Hello s4u, I'm ready to serve
+> [host1:master:(0) 0.000000] [s4u_test/INFO] Hello s4u, I have something to send
+> [host0:worker:(0) 0.001301] [s4u_test/INFO] I received 'GaBuZoMeu'
+> [host0:worker:(0) 0.001301] [s4u_test/INFO] I'm done. See you.
+> [host1:master:(0) 0.001301] [s4u_test/INFO] I'm done. See you.
--- /dev/null
+/* Copyright (c) 2004-2015. 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 SIMGRID_S4U_S4U_H
+#define SIMGRID_S4U_S4U_H
+
+#include "simgrid/s4u/channel.hpp"
+#include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/host.hpp"
+#include "simgrid/s4u/process.hpp"
+
+#endif /* SIMGRID_S4U_S4U_H */
--- /dev/null
+/* Copyright (c) 2006-2015. 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 SIMGRID_S4U_CHANNEL_HPP
+#define SIMGRID_S4U_CHANNEL_HPP
+
+#include <boost/unordered_map.hpp>
+
+#include "simgrid/s4u/process.hpp"
+
+namespace simgrid {
+namespace s4u {
+
+/** @brief Channel
+ *
+ * Rendez-vous point for network communications, similar to URLs on which you could post and retrieve data.
+ * They are not network locations (you can post and retrieve on a given mailbox from anywhere on the network).
+ */
+class Channel {
+ friend Process;
+
+private:
+ Channel(const char*name, smx_rdv_t inferior);
+public:
+ ~Channel();
+
+protected:
+ smx_rdv_t getInferior() { return p_inferior; }
+
+public:
+ /** Retrieve the channel associated to the given string */
+ static Channel *byName(const char *name);
+
+private:
+ std::string p_name;
+ smx_rdv_t p_inferior;
+ static boost::unordered_map<std::string, Channel *> *channels;
+};
+}} // namespace simgrid::s4u
+
+#endif /* SIMGRID_S4U_CHANNEL_HPP */
--- /dev/null
+/* Copyright (c) 2006-2015. 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 SIMGRID_S4U_ENGINE_HPP
+#define SIMGRID_S4U_ENGINE_HPP
+
+namespace simgrid {
+namespace s4u {
+/** @brief Simulation engine
+ *
+ * This class is an interface to the simulation engine.
+ */
+class Engine {
+public:
+ /** Constructor, taking the command line parameters of your main function */
+ Engine(int *argc, char **argv);
+
+ /** @brief Load a platform file describing the environment
+ *
+ * The environment is either a XML file following the simgrid.dtd formalism, or a lua file.
+ * Some examples can be found in the directory examples/platforms.
+ */
+ void loadPlatform(const char *platf);
+
+ /** Registers the main function of a process that will be launched from the deployment file */
+ void register_function(const char*name, int (*code)(int,char**));
+
+ /** Registers a function as the default main function of processes
+ *
+ * It will be used as fallback when the function requested from the deployment file was not registered.
+ * It is used for trace-based simulations (see examples/msg/actions).
+ */
+ void register_default(int (*code)(int,char**));
+
+ /** @brief Load a deployment file and launch the processes that it contains */
+ void loadDeployment(const char *deploy);
+
+ /** @brief Run the simulation */
+ void run();
+
+ /** @brief Retrieve the simulation time */
+ static double getClock();
+
+};
+}} // namespace simgrid::sgo
+
+#endif /* SIMGRID_S4U_ENGINE_HPP */
--- /dev/null
+/* Copyright (c) 2006-2015. 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 SIMGRID_S4U_HOST_HPP
+#define SIMGRID_S4U_HOST_HPP
+
+#include <boost/unordered_map.hpp>
+
+#include "simgrid/simix.h"
+
+namespace simgrid {
+namespace s4u {
+
+class Process;
+
+/** @brief Simulated machine that can host some processes
+ *
+ * It represents some physical resource with computing and networking capabilities.
+ *
+ * All hosts are automatically created during the call of the method
+ * @link{simgrid::s4u::Engine::loadPlatform()}.
+ * You cannot create a host yourself.
+ *
+ * You can retrieve a particular host using @link{simgrid::s4u::Host.byName()},
+ * and processes can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}.
+ */
+class Host {
+private:
+ Host(const char *name);
+public:
+ /** Retrieves an host from its name. */
+ static s4u::Host *byName(std::string name);
+ /** Retrieves the host on which the current process is running */
+ static s4u::Host *current();
+
+ const char* getName();
+
+ /** Turn sthat host on if it was previously off
+ *
+ * All processes on that host which were marked autorestart will be restarted automatically.
+ * This call does nothing if the host is already on.
+ */
+ void turnOn();
+ /** Turns that host off. All processes are forcefully stopped. */
+ void turnOff();
+ /** Returns if that host is currently up and running */
+ bool isOn();
+
+
+ /** Allows to store user data on that host */
+ void setData(void *data) {p_userdata = data;}
+ /** Retrieves the previously stored data */
+ void* getData() {return p_userdata;}
+
+protected:
+ friend Process;
+ sg_host_t getInferior() {return p_sghost;}
+private:
+ void*p_userdata=NULL;
+ sg_host_t p_sghost;
+ static boost::unordered_map<std::string, s4u::Host *> *hosts;
+};
+
+}} // namespace simgrid::s4u
+
+#endif /* SIMGRID_S4U_HOST_HPP */
+
+#if 0
+/* Bindings to the MSG hosts */
+
+/* Copyright (c) 2006-2014. 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. */
+
+package org.simgrid.msg;
+
+import org.simgrid.msg.Storage;
+
+/*
+Host jacquelin;
+
+try {
+ jacquelin = Host.getByName("Jacquelin");
+} catch(HostNotFoundException e) {
+ System.err.println(e.toString());
+}
+...
+\endverbatim
+ *
+ */
+public class Host {
+ /**
+ * This static method returns all of the hosts of the installed platform.
+ *
+ * @return An array containing all the hosts installed.
+ *
+ */
+ public native static Host[] all();
+
+ /**
+ * This static method sets a mailbox to receive in asynchronous mode.
+ *
+ * All messages sent to this mailbox will be transferred to
+ * the receiver without waiting for the receive call.
+ * The receive call will still be necessary to use the received data.
+ * If there is a need to receive some messages asynchronously, and some not,
+ * two different mailboxes should be used.
+ *
+ * @param mailboxName The name of the mailbox
+ */
+ public static native void setAsyncMailbox(String mailboxName);
+
+ /**
+ * This method returns the number of tasks currently running on a host.
+ * The external load (comming from an availability trace) is not taken in account.
+ *
+ * @return The number of tasks currently running on a host.
+ */
+ public native int getLoad();
+
+ /**
+ * This method returns the speed of the processor of a host,
+ * regardless of the current load of the machine.
+ *
+ * @return The speed of the processor of the host in flops.
+ *
+ */
+ public native double getSpeed();
+
+ /**
+ * This method returns the number of core of a host.
+ *
+ * @return The speed of the processor of the host in flops.
+ *
+ */
+ public native double getCoreNumber();
+
+ /**
+ * Returns the value of a given host property (set from the platform file).
+ */
+ public native String getProperty(String name);
+
+ /**
+ * Change the value of a given host property.
+ */
+ public native void setProperty(String name, String value);
+
+ /** This methods returns the list of mount point names on an host
+ * @return An array containing all mounted storages on the host
+ */
+ public native Storage[] getMountedStorage();
+
+ /** This methods returns the list of storages attached to an host
+ * @return An array containing all storages (name) attached to the host
+ */
+ public native String[] getAttachedStorage();
+
+
+}
+#endif
--- /dev/null
+/* Copyright (c) 2006-2015. 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 SIMGRID_S4U_PROCESS_HPP
+#define SIMGRID_S4U_PROCESS_HPP
+
+#include "simgrid/simix.h"
+
+namespace simgrid {
+namespace s4u {
+
+class Host;
+class Channel;
+
+/** @brief Simulation Agent
+ *
+ * A process may be defined as a code executing in a location (host).
+ *
+ * All processes should be started from the XML deployment file (using the @link{s4u::Engine::loadDeployment()}),
+ * even if you can also start new processes directly.
+ * Separating the deployment in the XML from the logic in the code is a good habit as it makes your simulation easier
+ * to adapt to new settings.
+ *
+ * The code that you define for a given process should be placed in the main method that is virtual.
+ * For example, a Worker process should be declared as follows:
+ *
+ * \verbatim
+ * #include "s4u/process.hpp"
+ *
+ * class Worker : simgrid::s4u::Process {
+ *
+ * int main(int argc, char **argv) {
+ * printf("Hello s4u");
+ * }
+ * };
+ * \endverbatim
+ *
+ */
+class Process {
+public:
+ Process(const char*procname, s4u::Host *host, int argc, char **argv);
+ Process(const char*procname, s4u::Host *host, int argc, char **argv, double killTime);
+ virtual ~Process() {}
+
+ /** The main method of your agent */
+ virtual int main(int argc, char **argv)=0;
+
+ /** The process that is currently running */
+ static Process *current();
+ /** Retrieves the process that have the given PID (or NULL if not existing) */
+ static Process *byPid(int pid);
+
+ /** Retrieves the name of that process */
+ const char*getName();
+ /** Retrieves the host on which that process is running */
+ s4u::Host *getHost();
+ /** Retrieves the PID of that process */
+ int getPid();
+
+ /** If set to true, the process will automatically restart when its host reboots */
+ void setAutoRestart(bool autorestart);
+ /** Sets the time at which that process should be killed */
+ void setKillTime(double time);
+ /** Retrieves the time at which that process will be killed (or -1 if not set) */
+ double getKillTime();
+
+ /** Ask kindly to all processes to die. Only the issuer will survive. */
+ static void killAll();
+ /** Ask the process to die.
+ *
+ * It will only notice your request when doing a simcall next time (a communication or similar).
+ * SimGrid sometimes have issues when you kill processes that are currently communicating and such. We are working on it to fix the issues.
+ */
+ void kill();
+
+ /** Block the process sleeping for that amount of seconds (may throws hostFailure) */
+ void sleep(double duration);
+
+ /** Block the process, computing the given amount of flops */
+ void execute(double flop);
+
+ /** Block the process until it gets a message from the given mailbox */
+ //void* recv(const char *mailbox);
+
+ /** Block the process until it gets a string message (to be freed after use) from the given mailbox */
+ char *recvstr(Channel &chan);
+
+ /** Block the process until it delivers a string message (that will be copied) to the given mailbox */
+ void sendstr(Channel &chan, const char*msg);
+
+protected:
+ smx_process_t getInferior() {return p_smx_process;}
+private:
+ smx_process_t p_smx_process;
+};
+}} // namespace simgrid::s4u
+
+#endif /* SIMGRID_S4U_PROCESS_HPP */
+
+#if 0
+
+public abstract class Process implements Runnable {
+ /** Suspends the process. See {@link #resume()} to resume it afterward */
+ public native void suspend();
+ /** Resume a process that was suspended by {@link #suspend()}. */
+ public native void resume();
+ /** Tests if a process is suspended. */
+ public native boolean isSuspended();
+
+ /**
+ * Returns the value of a given process property.
+ */
+ public native String getProperty(String name);
+
+
+ /**
+ * Migrates a process to another host.
+ *
+ * @param host The host where to migrate the process.
+ *
+ */
+ public native void migrate(Host host);
+
+ public native void exit();
+ /**
+ * This static method returns the current amount of processes running
+ *
+ * @return The count of the running processes
+ */
+ public native static int getCount();
+
+}
+#endif
--- /dev/null
+/* Copyright (c) 2006-2015. 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 "xbt/log.h"
+#include "msg/msg_private.h"
+#include "msg/msg_mailbox.h"
+
+#include "simgrid/s4u/channel.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_channel,"S4U Communication Channels");
+
+
+using namespace simgrid;
+
+boost::unordered_map <std::string, s4u::Channel *> *s4u::Channel::channels = new boost::unordered_map<std::string, s4u::Channel*> ();
+
+
+s4u::Channel::Channel(const char*name, smx_rdv_t inferior) {
+ p_inferior = inferior;
+ channels->insert({name, this});
+}
+s4u::Channel *s4u::Channel::byName(const char*name) {
+ s4u::Channel * res;
+ try {
+ res = channels->at(name);
+ } catch (std::out_of_range& e) {
+ res = new Channel(name,simcall_rdv_create(name));
+ }
+ return res;
+}
--- /dev/null
+/* s4u::Engine Simulation Engine and global functions. */
+
+/* Copyright (c) 2006-2015. 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/simix.h"
+#include "mc/mc.h"
+#include "simgrid/s4u/engine.hpp"
+
+
+using namespace simgrid;
+
+double s4u::Engine::getClock() {
+ return SIMIX_get_clock();
+}
+
+s4u::Engine::Engine(int *argc, char **argv) {
+ SIMIX_global_init(argc, argv);
+}
+
+void s4u::Engine::loadPlatform(const char *platf) {
+ SIMIX_create_environment(platf);
+}
+
+void s4u::Engine::register_function(const char*name, int (*code)(int,char**)) {
+ SIMIX_function_register(name,code);
+}
+void s4u::Engine::register_default(int (*code)(int,char**)) {
+ SIMIX_function_register_default(code);
+}
+void s4u::Engine::loadDeployment(const char *deploy) {
+ SIMIX_launch_application(deploy);
+}
+
+void s4u::Engine::run() {
+ if (MC_is_active()) {
+ MC_run();
+ } else {
+ SIMIX_run();
+ }
+}
--- /dev/null
+/* Copyright (c) 2006-2014. 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 "xbt/log.h"
+#include "msg/msg_private.h"
+#include "simix/smx_process_private.h"
+
+#include "simgrid/s4u/host.hpp"
+
+using namespace simgrid;
+
+boost::unordered_map<std::string, simgrid::s4u::Host*> *simgrid::s4u::Host::hosts
+ = new boost::unordered_map<std::string, simgrid::s4u::Host*>();
+
+s4u::Host::Host(const char*name) {
+ p_sghost = sg_host_by_name(name);
+ if (p_sghost==NULL)
+ xbt_die("No such host: %s",name); //FIXME: raise an exception
+}
+
+s4u::Host *s4u::Host::byName(std::string name) {
+ s4u::Host * res = NULL;
+ try {
+ res = hosts->at(name);
+ } catch (std::out_of_range& e) {}
+
+ if (res==NULL) {
+ res = new s4u::Host(name.c_str());
+ hosts->insert({name,res});
+ }
+ return res;
+}
+s4u::Host *s4u::Host::current(){
+ smx_process_t smx_proc = SIMIX_process_self();
+ if (smx_proc == NULL)
+ xbt_die("Cannot call Host::current() from the maestro context");
+
+ return s4u::Host::byName(SIMIX_host_get_name(SIMIX_process_get_host(smx_proc)));
+}
+
+const char* s4u::Host::getName() {
+ return sg_host_name(p_sghost);
+}
+
+void s4u::Host::turnOn() {
+ simcall_host_on(p_sghost);
+}
+void s4u::Host::turnOff() {
+ simcall_host_off(p_sghost);
+}
+bool s4u::Host::isOn() {
+ return simcall_host_get_state(p_sghost);
+}
--- /dev/null
+/* Copyright (c) 2006-2014. 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 "xbt/log.h"
+#include "msg/msg_private.h"
+#include "msg/msg_mailbox.h"
+
+#include "simgrid/s4u/host.hpp"
+#include "simgrid/s4u/process.hpp"
+#include "simgrid/s4u/channel.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_process,"S4U processes");
+
+/* C main function of a process, running this->main */
+static int s4u_process_runner(int argc, char **argv) {
+
+ smx_process_t smx_proc = SIMIX_process_self();
+ simgrid::s4u::Process *proc = (simgrid::s4u::Process*) SIMIX_process_self_get_data(smx_proc);
+ int res= proc->main(argc,argv);
+ return res;
+}
+
+
+
+using namespace simgrid;
+
+s4u::Process::Process(const char *procname, s4u::Host *host, int argc, char **argv)
+ : s4u::Process::Process(procname,host, argc,argv, -1) {
+}
+s4u::Process::Process(const char *procname, s4u::Host *host, int argc, char **argv, double killTime) {
+ p_smx_process = simcall_process_create(procname, s4u_process_runner, this, host->getName(), killTime, argc, argv, NULL/*properties*/,0);
+
+ xbt_assert(p_smx_process,"Cannot create the process");
+// TRACE_msg_process_create(procname, simcall_process_get_PID(p_smx_process), host->getInferior());
+// simcall_process_on_exit(p_smx_process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,p_smx_process);
+}
+
+s4u::Process *s4u::Process::current() {
+ smx_process_t smx_proc = SIMIX_process_self();
+ return (simgrid::s4u::Process*) SIMIX_process_self_get_data(smx_proc);
+}
+s4u::Process *s4u::Process::byPid(int pid) {
+ return (simgrid::s4u::Process*) SIMIX_process_self_get_data(SIMIX_process_from_PID(pid));
+}
+
+void s4u::Process::setAutoRestart(bool autorestart) {
+ simcall_process_auto_restart_set(p_smx_process,autorestart);
+}
+
+s4u::Host *s4u::Process::getHost() {
+ return s4u::Host::byName(sg_host_name(simcall_process_get_host(p_smx_process)));
+}
+const char* s4u::Process::getName() {
+ return simcall_process_get_name(p_smx_process);
+}
+int s4u::Process::getPid(){
+ return simcall_process_get_PID(p_smx_process);
+}
+
+void s4u::Process::setKillTime(double time) {
+ simcall_process_set_kill_time(p_smx_process,time);
+}
+double s4u::Process::getKillTime() {
+ return simcall_process_get_kill_time(p_smx_process);
+}
+void s4u::Process::killAll() {
+ simcall_process_killall(1);
+}
+void s4u::Process::kill() {
+ simcall_process_kill(p_smx_process);
+}
+
+void s4u::Process::sleep(double duration) {
+ simcall_process_sleep(duration);
+}
+
+void s4u::Process::execute(double flops) {
+ simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
+}
+
+char *s4u::Process::recvstr(Channel &chan) {
+ char *res=NULL;
+ size_t res_size=sizeof(res);
+
+ simcall_comm_recv(chan.getInferior(),&res,&res_size,NULL,NULL,NULL,-1 /* timeout */,-1 /*rate*/);
+
+ return res;
+}
+void s4u::Process::sendstr(Channel &chan, const char*msg) {
+ char *msg_cpy=xbt_strdup(msg);
+ smx_synchro_t comm = simcall_comm_isend(p_smx_process, chan.getInferior(), strlen(msg),
+ -1/*rate*/, msg_cpy, sizeof(void *),
+ NULL, NULL, NULL,NULL/*data*/, 0);
+ simcall_comm_wait(comm, -1/*timeout*/);
+}
+