From: Martin Quinson Date: Sun, 20 Jan 2019 11:19:38 +0000 (+0100) Subject: s/process/actor/ A lot remains TBD about it X-Git-Tag: v3_22~529 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/465dac153770a28f3a334705a06a1ee7a457c965?hp=19016c1363a1c0409a35940ad406e88057fdba73 s/process/actor/ A lot remains TBD about it --- diff --git a/src/bindings/java/JavaContext.cpp b/src/bindings/java/JavaContext.cpp index 7cc00a21ac..4a742fd7a1 100644 --- a/src/bindings/java/JavaContext.cpp +++ b/src/bindings/java/JavaContext.cpp @@ -78,7 +78,7 @@ void JavaContext::stop() // (as the ones created for the VM migration). The Java exception will not be catched anywhere. // Bad things happen currently if these actors get killed, unfortunately. jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", - std::string("Process ") + this->process()->get_cname() + " killed from file JavaContext.cpp"); + std::string("Process ") + this->get_actor()->get_cname() + " killed from file JavaContext.cpp"); // (remember that throwing a java exception from C does not break the C execution path. // Instead, it marks the exception to be raised when returning to the Java world and diff --git a/src/kernel/context/Context.hpp b/src/kernel/context/Context.hpp index 9a6ace7189..10ddbe6000 100644 --- a/src/kernel/context/Context.hpp +++ b/src/kernel/context/Context.hpp @@ -57,14 +57,14 @@ private: public: bool iwannadie = false; - Context(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process); + Context(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor); Context(const Context&) = delete; Context& operator=(const Context&) = delete; virtual ~Context(); void operator()() { code_(); } bool has_code() const { return static_cast(code_); } - smx_actor_t process() { return this->actor_; } + smx_actor_t get_actor() { return this->actor_; } void set_cleanup(void_pfn_smxprocess_t cleanup) { cleanup_func_ = cleanup; } // Scheduling methods diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index ac88b6833a..e229a5c115 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -23,9 +23,9 @@ smx_context_t BoostContextFactory::create_context(std::function code, vo // BoostContext -BoostContext::BoostContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, +BoostContext::BoostContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, SwappedContextFactory* factory) - : SwappedContext(std::move(code), cleanup_func, process, factory) + : SwappedContext(std::move(code), cleanup_func, actor, factory) { /* if the user provided a function for the process then use it, otherwise it is the context for maestro */ diff --git a/src/kernel/context/ContextBoost.hpp b/src/kernel/context/ContextBoost.hpp index 99dad30f29..d78cc2336d 100644 --- a/src/kernel/context/ContextBoost.hpp +++ b/src/kernel/context/ContextBoost.hpp @@ -32,7 +32,7 @@ namespace context { /** @brief Userspace context switching implementation based on Boost.Context */ class BoostContext : public SwappedContext { public: - BoostContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, + BoostContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, SwappedContextFactory* factory); ~BoostContext() override; diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index 3b2906237b..ffffc650d1 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -194,9 +194,9 @@ Context* RawContextFactory::create_context(std::function code, void_pfn_ // RawContext -RawContext::RawContext(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t process, +RawContext::RawContext(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t actor, SwappedContextFactory* factory) - : SwappedContext(std::move(code), cleanup, process, factory) + : SwappedContext(std::move(code), cleanup, actor, factory) { if (has_code()) { #if PTH_STACKGROWTH == -1 diff --git a/src/kernel/context/ContextRaw.hpp b/src/kernel/context/ContextRaw.hpp index 89e72bc46b..a27e81b33b 100644 --- a/src/kernel/context/ContextRaw.hpp +++ b/src/kernel/context/ContextRaw.hpp @@ -26,7 +26,7 @@ namespace context { */ class RawContext : public SwappedContext { public: - RawContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, + RawContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, SwappedContextFactory* factory); void swap_into(SwappedContext* to) override; diff --git a/src/kernel/context/ContextSwapped.hpp b/src/kernel/context/ContextSwapped.hpp index 77bbbf17c5..60d998777e 100644 --- a/src/kernel/context/ContextSwapped.hpp +++ b/src/kernel/context/ContextSwapped.hpp @@ -35,7 +35,7 @@ private: class SwappedContext : public Context { public: - SwappedContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, + SwappedContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t get_actor, SwappedContextFactory* factory); virtual ~SwappedContext(); diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index a3c60882e0..64188a62f8 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -36,12 +36,12 @@ ThreadContextFactory::~ThreadContextFactory() } ThreadContext* ThreadContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup, - smx_actor_t process, bool maestro) + smx_actor_t actor, bool maestro) { if (parallel_) - return this->new_context(std::move(code), cleanup, process, maestro); + return this->new_context(std::move(code), cleanup, actor, maestro); else - return this->new_context(std::move(code), cleanup, process, maestro); + return this->new_context(std::move(code), cleanup, actor, maestro); } void ThreadContextFactory::run_all() @@ -60,11 +60,11 @@ void ThreadContextFactory::run_all() ThreadContext::ThreadContext(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t actor, bool maestro) : AttachContext(std::move(code), cleanup, actor), is_maestro_(maestro) { - /* If the user provided a function for the process then use it */ + /* If the user provided a function for the actor then use it */ if (has_code()) { - /* create and start the process */ + /* create and start the actor */ this->thread_ = new std::thread(ThreadContext::wrapper, this); - /* wait the starting of the newly created process */ + /* wait the starting of the newly created actor */ this->end_.acquire(); } @@ -178,9 +178,9 @@ void ThreadContext::attach_stop() void SerialThreadContext::run_all() { - for (smx_actor_t const& process : simix_global->process_to_run) { - XBT_DEBUG("Handling %p", process); - ThreadContext* context = static_cast(process->context_); + for (smx_actor_t const& actor : simix_global->process_to_run) { + XBT_DEBUG("Handling %p", actor); + ThreadContext* context = static_cast(actor->context_); context->release(); context->wait(); } @@ -203,10 +203,10 @@ void ParallelThreadContext::finalize() void ParallelThreadContext::run_all() { - for (smx_actor_t const& process : simix_global->process_to_run) - static_cast(process->context_)->release(); - for (smx_actor_t const& process : simix_global->process_to_run) - static_cast(process->context_)->wait(); + for (smx_actor_t const& actor : simix_global->process_to_run) + static_cast(actor->context_)->release(); + for (smx_actor_t const& actor : simix_global->process_to_run) + static_cast(actor->context_)->wait(); } void ParallelThreadContext::start_hook() diff --git a/src/kernel/context/ContextThread.hpp b/src/kernel/context/ContextThread.hpp index 4c76ae2e38..623aec4733 100644 --- a/src/kernel/context/ContextThread.hpp +++ b/src/kernel/context/ContextThread.hpp @@ -20,7 +20,7 @@ namespace context { class XBT_PUBLIC ThreadContext : public AttachContext { public: - ThreadContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, bool maestro); + ThreadContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, bool maestro); ~ThreadContext() override; void stop() override; void suspend() override; @@ -34,7 +34,7 @@ public: private: /** A portable thread */ std::thread* thread_ = nullptr; - /** Semaphore used to schedule/yield the process (not needed when the maestro is in main, but harmless then) */ + /** Semaphore used to schedule/yield the actor (not needed when the maestro is in main, but harmless then) */ xbt::OsSemaphore begin_{0}; /** Semaphore used to schedule/unschedule (not needed when the maestro is in main, but harmless then) */ xbt::OsSemaphore end_{0}; @@ -50,8 +50,8 @@ private: class XBT_PUBLIC SerialThreadContext : public ThreadContext { public: - SerialThreadContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, bool maestro) - : ThreadContext(std::move(code), cleanup_func, process, maestro) + SerialThreadContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, bool maestro) + : ThreadContext(std::move(code), cleanup_func, actor, maestro) { } @@ -60,9 +60,8 @@ public: class ParallelThreadContext : public ThreadContext { public: - ParallelThreadContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, - bool maestro) - : ThreadContext(std::move(code), cleanup_func, process, maestro) + ParallelThreadContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, bool maestro) + : ThreadContext(std::move(code), cleanup_func, actor, maestro) { } @@ -82,27 +81,27 @@ public: ThreadContextFactory(); ~ThreadContextFactory() override; ThreadContext* create_context(std::function code, void_pfn_smxprocess_t cleanup_func, - smx_actor_t process) override + smx_actor_t actor) override { bool maestro = not code; - return create_context(std::move(code), cleanup_func, process, maestro); + return create_context(std::move(code), cleanup_func, actor, maestro); } void run_all() override; // Optional methods: - ThreadContext* attach(void_pfn_smxprocess_t cleanup_func, smx_actor_t process) override + ThreadContext* attach(void_pfn_smxprocess_t cleanup_func, smx_actor_t actor) override { - return create_context(std::function(), cleanup_func, process, false); + return create_context(std::function(), cleanup_func, actor, false); } - ThreadContext* create_maestro(std::function code, smx_actor_t process) override + ThreadContext* create_maestro(std::function code, smx_actor_t actor) override { - return create_context(std::move(code), nullptr, process, true); + return create_context(std::move(code), nullptr, actor, true); } private: bool parallel_; - ThreadContext* create_context(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, + ThreadContext* create_context(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, bool maestro); }; }}} // namespace diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index 1b0398ee56..de67f76e93 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -30,17 +30,17 @@ namespace kernel { namespace context { // UContextFactory -Context* UContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t process) +Context* UContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t actor) { - return new_context(std::move(code), cleanup, process, this); + return new_context(std::move(code), cleanup, actor, this); } // UContext -UContext::UContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, +UContext::UContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, SwappedContextFactory* factory) - : SwappedContext(std::move(code), cleanup_func, process, factory) + : SwappedContext(std::move(code), cleanup_func, actor, factory) { /* if the user provided a function for the process then use it, otherwise it is the context for maestro */ if (has_code()) { @@ -58,7 +58,7 @@ UContext::UContext(std::function code, void_pfn_smxprocess_t cleanup_fun #if SIMGRID_HAVE_MC if (MC_is_active() && has_code()) { - MC_register_stack_area(get_stack(), process, &(this->uc_), smx_context_usable_stack_size); + MC_register_stack_area(get_stack(), actor, &(this->uc_), smx_context_usable_stack_size); } #endif } diff --git a/src/kernel/context/ContextUnix.hpp b/src/kernel/context/ContextUnix.hpp index 211da7e48c..d3b3659509 100644 --- a/src/kernel/context/ContextUnix.hpp +++ b/src/kernel/context/ContextUnix.hpp @@ -25,7 +25,7 @@ namespace context { class UContext : public SwappedContext { public: - UContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, + UContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor, SwappedContextFactory* factory); void swap_into(SwappedContext* to) override; diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 3869be94f6..f5c00f3e8a 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -35,7 +35,7 @@ ActorPtr Actor::self() if (self_context == nullptr) return simgrid::s4u::ActorPtr(); - return self_context->process()->iface(); + return self_context->get_actor()->iface(); } ActorPtr Actor::create(std::string name, s4u::Host* host, std::function code) diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 9f72900aa3..353b70d029 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -36,7 +36,7 @@ smx_actor_t SIMIX_process_self() { smx_context_t self_context = simgrid::kernel::context::Context::self(); - return (self_context != nullptr) ? self_context->process() : nullptr; + return (self_context != nullptr) ? self_context->get_actor() : nullptr; } /** @@ -430,7 +430,7 @@ void SIMIX_process_detach() if (context == nullptr) xbt_die("Not a suitable context"); - SIMIX_process_cleanup(context->process()); + SIMIX_process_cleanup(context->get_actor()); context->attach_stop(); }