X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/55092bf3f9fe1cccfe72f7ef81fcd51f9a0eb4ca..05736ee0ede974fcf9fb60a13a40c50d62fcc19d:/src/kernel/context/ContextUnix.cpp diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index 35154dd697..226236e1b6 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -1,20 +1,16 @@ -/* Copyright (c) 2009-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2009-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. */ -/* \file UContext.cpp Context switching with ucontexts from System V */ +/* \file UContext.cpp Context switching with ucontexts from System V */ -#include - -#include #include /* context relative declarations */ -#include "xbt/parmap.h" -#include "src/simix/smx_private.h" -#include "src/internal_config.h" #include "mc/mc.h" +#include "src/simix/ActorImpl.hpp" +#include "src/simix/smx_private.h" +#include "xbt/parmap.h" /** Many integers are needed to store a pointer * @@ -82,14 +78,14 @@ protected: public: friend UContextFactory; UContext(std::function code, - void_pfn_smxprocess_t cleanup_func, smx_process_t process); + void_pfn_smxprocess_t cleanup_func, smx_actor_t process); ~UContext() override; }; class SerialUContext : public UContext { public: SerialUContext(std::function code, - void_pfn_smxprocess_t cleanup_func, smx_process_t process) + void_pfn_smxprocess_t cleanup_func, smx_actor_t process) : UContext(std::move(code), cleanup_func, process) {} void stop() override; @@ -100,7 +96,7 @@ public: class ParallelUContext : public UContext { public: ParallelUContext(std::function code, - void_pfn_smxprocess_t cleanup_func, smx_process_t process) + void_pfn_smxprocess_t cleanup_func, smx_actor_t process) : UContext(std::move(code), cleanup_func, process) {} void stop() override; @@ -117,7 +113,7 @@ public: UContextFactory(); ~UContextFactory() override; Context* create_context(std::function code, - void_pfn_smxprocess_t cleanup, smx_process_t process) override; + void_pfn_smxprocess_t cleanup, smx_actor_t process) override; void run_all() override; }; @@ -176,7 +172,7 @@ void UContextFactory::run_all() xbt_parmap_apply(sysv_parmap, [](void* arg) { - smx_process_t process = (smx_process_t) arg; + smx_actor_t process = (smx_actor_t) arg; ParallelUContext* context = static_cast(process->context); context->resume(); }, @@ -186,17 +182,20 @@ void UContextFactory::run_all() #endif } else { // Serial: - smx_process_t first_process = - xbt_dynar_get_as(simix_global->process_to_run, 0, smx_process_t); - sysv_process_index = 1; - SerialUContext* context = + if (xbt_dynar_is_empty(simix_global->process_to_run)) + return; + + smx_actor_t first_process = + xbt_dynar_get_as(simix_global->process_to_run, 0, smx_actor_t); + sysv_process_index = 1; + SerialUContext* context = static_cast(first_process->context); - context->resume(); + context->resume(); } } Context* UContextFactory::create_context(std::function code, - void_pfn_smxprocess_t cleanup, smx_process_t process) + void_pfn_smxprocess_t cleanup, smx_actor_t process) { if (sysv_parallel) return new_context(std::move(code), cleanup, process); @@ -205,7 +204,7 @@ Context* UContextFactory::create_context(std::function code, } UContext::UContext(std::function code, - void_pfn_smxprocess_t cleanup_func, smx_process_t process) + void_pfn_smxprocess_t cleanup_func, smx_actor_t process) : Context(std::move(code), cleanup_func, process) { /* if the user provided a function for the process then use it, otherwise it is the context for maestro */ @@ -275,7 +274,7 @@ void SerialUContext::suspend() /* execute the next process */ XBT_DEBUG("Run next process"); next_context = (SerialUContext*) xbt_dynar_get_as( - simix_global->process_to_run,i, smx_process_t)->context; + simix_global->process_to_run,i, smx_actor_t)->context; } else { /* all processes were run, return to maestro */ @@ -347,7 +346,7 @@ void ParallelUContext::suspend() #if HAVE_THREAD_CONTEXTS /* determine the next context */ // Get the next soul to embody now: - smx_process_t next_work = (smx_process_t) xbt_parmap_next(sysv_parmap); + smx_actor_t next_work = (smx_actor_t) xbt_parmap_next(sysv_parmap); ParallelUContext* next_context = nullptr; // Will contain the next soul to run, either simulated or initial minion's one ucontext_t* next_stack;