1 /* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_SIMIX_RAW_CONTEXT_HPP
7 #define SIMGRID_SIMIX_RAW_CONTEXT_HPP
14 #include <xbt/parmap.hpp>
16 #include "src/kernel/context/ContextSwapped.hpp"
22 /** @brief Fast context switching inspired from SystemV ucontexts.
24 * The main difference to the System V context is that Raw Contexts are much faster because they don't
25 * preserve the signal mask when switching. This saves a system call (at least on Linux) on each context switch.
27 class RawContext : public SwappedContext {
29 RawContext(std::function<void()> code, smx_actor_t actor, SwappedContextFactory* factory);
31 void swap_into(SwappedContext* to) override;
34 /** pointer to top the stack stack */
35 void* stack_top_ = nullptr;
37 static void wrapper(void* arg);
40 class RawContextFactory : public SwappedContextFactory {
42 Context* create_context(std::function<void()> code, smx_actor_t actor) override;