XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
-class Worker : Process {
+class Worker : Actor {
public:
Worker(const char*procname, Host *host,int argc, char **argv)
- : s4u::Process(procname,host,argc,argv){}
+ : s4u::Actor(procname,host,argc,argv){}
int main(int argc, char **argv) {
XBT_INFO("Hello s4u, I'm ready to serve");
}
};
-class Master : Process {
+class Master : Actor {
public:
Master(const char*procname, Host *host,int argc, char **argv)
- : Process(procname,host,argc,argv){}
+ : Actor(procname,host,argc,argv){}
int main(int argc, char **argv) {
XBT_INFO("Hello s4u, I have something to send");
#ifndef SIMGRID_S4U_S4U_H
#define SIMGRID_S4U_S4U_H
+#include "s4u/actor.hpp"
#include "s4u/mailbox.hpp"
#include "simgrid/s4u/engine.hpp"
#include "simgrid/s4u/host.hpp"
-#include "simgrid/s4u/process.hpp"
#endif /* SIMGRID_S4U_S4U_H */
/* 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
+#ifndef SIMGRID_S4U_ACTOR_HPP
+#define SIMGRID_S4U_ACTOR_HPP
#include "simgrid/simix.h"
/** @brief Simulation Agent
*
- * A process may be defined as a code executing in a location (host).
+ * An actor 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.
+ * All actors should be started from the XML deployment file (using the @link{s4u::Engine::loadDeployment()}),
+ * even if you can also start new actors 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:
+ * The code that you define for a given actor should be placed in the main method that is virtual.
+ * For example, a Worker actor should be declared as follows:
*
* \verbatim
- * #include "s4u/process.hpp"
+ * #include "s4u/actor.hpp"
*
- * class Worker : simgrid::s4u::Process {
+ * class Worker : simgrid::s4u::Actor {
*
* int main(int argc, char **argv) {
* printf("Hello s4u");
* \endverbatim
*
*/
-class Process {
+class Actor {
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() {}
+ Actor(const char*name, s4u::Host *host, int argc, char **argv);
+ Actor(const char*name, s4u::Host *host, int argc, char **argv, double killTime);
+ virtual ~Actor() {}
/** 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);
+ /** The Actor that is currently running */
+ static Actor *current();
+ /** Retrieves the actor that have the given PID (or NULL if not existing) */
+ static Actor *byPid(int pid);
- /** Retrieves the name of that process */
+ /** Retrieves the name of that actor */
const char*getName();
- /** Retrieves the host on which that process is running */
+ /** Retrieves the host on which that actor is running */
s4u::Host *getHost();
- /** Retrieves the PID of that process */
+ /** Retrieves the PID of that actor */
int getPid();
- /** If set to true, the process will automatically restart when its host reboots */
+ /** If set to true, the actor will automatically restart when its host reboots */
void setAutoRestart(bool autorestart);
- /** Sets the time at which that process should be killed */
+ /** Sets the time at which that actor should be killed */
void setKillTime(double time);
- /** Retrieves the time at which that process will be killed (or -1 if not set) */
+ /** Retrieves the time at which that actor will be killed (or -1 if not set) */
double getKillTime();
- /** Ask kindly to all processes to die. Only the issuer will survive. */
+ /** Ask kindly to all actors to die. Only the issuer will survive. */
static void killAll();
- /** Ask the process to die.
+ /** Ask the actor 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.
+ * SimGrid sometimes have issues when you kill actors 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) */
+ /** Block the actor sleeping for that amount of seconds (may throws hostFailure) */
void sleep(double duration);
- /** Block the process, computing the given amount of flops */
+ /** Block the actor, computing the given amount of flops */
void execute(double flop);
- /** Block the process until it gets a message from the given mailbox */
+ /** Block the actor 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 */
+ /** Block the actor until it gets a string message (to be freed after use) from the given mailbox */
char *recvstr(Mailbox &chan);
- /** Block the process until it delivers a string message (that will be copied) to the given mailbox */
+ /** Block the actor until it delivers a string message (that will be copied) to the given mailbox */
void sendstr(Mailbox &chan, const char*msg);
protected:
};
}} // namespace simgrid::s4u
-#endif /* SIMGRID_S4U_PROCESS_HPP */
+#endif /* SIMGRID_S4U_ACTOR_HPP */
#if 0
-public abstract class Process implements Runnable {
+public abstract class Actor 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()}. */
*/
void loadPlatform(const char *platf);
- /** Registers the main function of a process that will be launched from the deployment file */
+ /** Registers the main function of an actor 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
+ /** Registers a function as the default main function of actors
*
* 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 */
+ /** @brief Load a deployment file and launch the actors that it contains */
void loadDeployment(const char *deploy);
/** @brief Run the simulation */
namespace simgrid {
namespace s4u {
-class Process;
+class Actor;
-/** @brief Simulated machine that can host some processes
+/** @brief Simulated machine that can host some actors
*
* It represents some physical resource with computing and networking capabilities.
*
* 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()}.
+ * and actors can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}.
*/
class Host {
private:
public:
/** Retrieves an host from its name. */
static s4u::Host *byName(std::string name);
- /** Retrieves the host on which the current process is running */
+ /** Retrieves the host on which the current actor is running */
static s4u::Host *current();
const char* getName();
- /** Turn sthat host on if it was previously off
+ /** Turns that host on if it was previously off
*
- * All processes on that host which were marked autorestart will be restarted automatically.
+ * All actors 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. */
+ /** Turns that host off. All actors are forcefully stopped. */
void turnOff();
/** Returns if that host is currently up and running */
bool isOn();
void* getData() {return p_userdata;}
protected:
- friend Process;
+ friend Actor;
sg_host_t getInferior() {return p_sghost;}
private:
void*p_userdata=NULL;
#include <boost/unordered_map.hpp>
-#include "simgrid/s4u/process.hpp"
+#include "actor.hpp"
namespace simgrid {
namespace s4u {
* sender and receiver.
*/
class Mailbox {
- friend Process;
+ friend Actor;
private:
Mailbox(const char*name, smx_rdv_t inferior);
/* 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 "../../include/simgrid/s4u/actor.hpp"
#include "../../include/simgrid/s4u/mailbox.hpp"
#include "xbt/log.h"
#include "msg/msg_private.h"
#include "msg/msg_mailbox.h"
#include "simgrid/s4u/host.hpp"
-#include "simgrid/s4u/process.hpp"
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_process,"S4U processes");
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor,"S4U actors");
-/* C main function of a process, running this->main */
-static int s4u_process_runner(int argc, char **argv) {
+/* C main function of a actor, running this->main */
+static int s4u_actor_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);
+ simgrid::s4u::Actor *actor = (simgrid::s4u::Actor*) SIMIX_process_self_get_data(smx_proc);
+ int res = actor->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::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv)
+ : s4u::Actor::Actor(name,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);
+s4u::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv, double killTime) {
+ p_smx_process = simcall_process_create(name, s4u_actor_runner, this, host->getName(), killTime, argc, argv, NULL/*properties*/,0);
- xbt_assert(p_smx_process,"Cannot create the process");
+ xbt_assert(p_smx_process,"Cannot create the actor");
// 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() {
+s4u::Actor *s4u::Actor::current() {
smx_process_t smx_proc = SIMIX_process_self();
- return (simgrid::s4u::Process*) SIMIX_process_self_get_data(smx_proc);
+ return (simgrid::s4u::Actor*) 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));
+s4u::Actor *s4u::Actor::byPid(int pid) {
+ return (simgrid::s4u::Actor*) SIMIX_process_self_get_data(SIMIX_process_from_PID(pid));
}
-void s4u::Process::setAutoRestart(bool autorestart) {
+void s4u::Actor::setAutoRestart(bool autorestart) {
simcall_process_auto_restart_set(p_smx_process,autorestart);
}
-s4u::Host *s4u::Process::getHost() {
+s4u::Host *s4u::Actor::getHost() {
return s4u::Host::byName(sg_host_name(simcall_process_get_host(p_smx_process)));
}
-const char* s4u::Process::getName() {
+const char* s4u::Actor::getName() {
return simcall_process_get_name(p_smx_process);
}
-int s4u::Process::getPid(){
+int s4u::Actor::getPid(){
return simcall_process_get_PID(p_smx_process);
}
-void s4u::Process::setKillTime(double time) {
+void s4u::Actor::setKillTime(double time) {
simcall_process_set_kill_time(p_smx_process,time);
}
-double s4u::Process::getKillTime() {
+double s4u::Actor::getKillTime() {
return simcall_process_get_kill_time(p_smx_process);
}
-void s4u::Process::killAll() {
+void s4u::Actor::killAll() {
simcall_process_killall(1);
}
-void s4u::Process::kill() {
+void s4u::Actor::kill() {
simcall_process_kill(p_smx_process);
}
-void s4u::Process::sleep(double duration) {
+void s4u::Actor::sleep(double duration) {
simcall_process_sleep(duration);
}
-void s4u::Process::execute(double flops) {
+void s4u::Actor::execute(double flops) {
simcall_process_execute(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
}
-char *s4u::Process::recvstr(Mailbox &chan) {
+char *s4u::Actor::recvstr(Mailbox &chan) {
char *res=NULL;
size_t res_size=sizeof(res);
return res;
}
-void s4u::Process::sendstr(Mailbox &chan, const char*msg) {
+void s4u::Actor::sendstr(Mailbox &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 *),
endif()
set(S4U_SRC
+ src/s4u/s4u_actor.cpp
src/s4u/s4u_engine.cpp
src/s4u/s4u_host.cpp
src/s4u/s4u_mailbox.cpp
- src/s4u/s4u_process.cpp
)
set(SIMGRID_SRC
include/simgrid/simix.h
include/simgrid/host.h
include/simgrid/link.h
+ include/simgrid/s4u/actor.hpp
include/simgrid/s4u/engine.hpp
include/simgrid/s4u/host.hpp
include/simgrid/s4u/mailbox.hpp
- include/simgrid/s4u/process.hpp
include/simgrid/s4u.h
include/smpi/mpi.h
include/smpi/smpi.h