/* 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 RawContext.cpp
- * Fast context switching inspired from SystemV ucontexts.
- *
- * In contrast to System V context, it does not touch the signal mask
- * which avoids making a system call (at least on Linux).
- */
-
#include <math.h>
#include <utility>
#include "xbt/dynar.h"
#include "smx_private.h"
-#include "smx_private.hpp"
#include "mc/mc.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
class RawContext;
class RawContextFactory;
+/** @brief Fast context switching inspired from SystemV ucontexts.
+ *
+ * The main difference to the System V context is that Raw Contexts are much faster because they don't
+ * preserve the signal mask when switching. This saves a system call (at least on Linux) on each context switch.
+ */
class RawContext : public Context {
protected:
void* stack_ = nullptr;
RawContext(std::function<void()> code,
void_pfn_smxprocess_t cleanup_func,
smx_process_t process);
- ~RawContext();
+ ~RawContext() override;
public:
static void wrapper(void* arg);
void stop() override;
class RawContextFactory : public ContextFactory {
public:
RawContextFactory();
- ~RawContextFactory();
+ ~RawContextFactory() override;
RawContext* create_context(std::function<void()> code,
- void_pfn_smxprocess_t, smx_process_t process) override;
+ void_pfn_smxprocess_t cleanup, smx_process_t process) override;
void run_all() override;
private:
void run_all_adaptative();