SIMLIB/C++ 3.09
Loading...
Searching...
No Matches
process.cc File Reference

Implementation of quasiparallel processes (coroutines). More...

#include "simlib.h"
#include "internal.h"
#include <csetjmp>
#include <cstring>
Include dependency graph for process.cc:

Go to the source code of this file.

Classes

struct  simlib3::P_Context_t
 internal structure for storing of Process::Behavior() context More...

Namespaces

namespace  simlib3
 Implementation of class CalendarList
interface is static - using global functions in SQS namespace.

Macros

#define EXTRA_DEBUG   0
#define DEBUG_PROCESS(n)
#define PROCESS_INTERRUPT()
 interrupt process behavior execution, continue after return
#define PROCESS_EXIT()
 does not save context
#define CANARY1   (reinterpret_cast<long>(this)-1)
#define MAX_PROCESS_STACK_SIZE   1000000UL
 This is theoretical max stack size for single SIMLIB Process at time of interruption (should never be too big, because of copying the stack contents) FIXME: should be checked at Process::Behavior interrupt for more precise error message.
#define STACK_RESERVED   0x080
#define CANARY2   0xDEADBEEFUL

Functions

static void simlib3::PROCESS_INTERRUPT_f ()
 Special function called from Process::Behavior() directly or indirectly.
static void simlib3::ALLOC_CONTEXT (size_t sz) noexcept
static void simlib3::FREE_CONTEXT () noexcept
 deallocate saved process context
static void simlib3::restore_context2 (volatile char *) noexcept
 This function overwrites stack contents. It never returns, see longjmp.
static void simlib3::restore_context (size_t data_size) noexcept
 This elliminates the need for explicit stack pointer adjustment.

Variables

static jmp_buf simlib3::P_DispatcherStatusBuffer
 setjmp() state before dispatch
static char *volatile simlib3::P_StackBase = 0
 global start of stack area
static char *volatile simlib3::P_StackBase2 = 0
 used for checking only
static P_Context_t *volatile simlib3::P_Context = 0
 temporary global process state
static volatile size_t simlib3::P_StackSize = 0
 temporary global stack size

Detailed Description

Implementation of quasiparallel processes (coroutines).

This module contains implementation of cooperative multitasking processes for discrete simulation

Definition in file process.cc.

Macro Definition Documentation

◆ CANARY1

#define CANARY1   (reinterpret_cast<long>(this)-1)

Definition at line 352 of file process.cc.

Referenced by simlib3::Process::_Run().

◆ CANARY2

#define CANARY2   0xDEADBEEFUL

Definition at line 538 of file process.cc.

Referenced by simlib3::PROCESS_INTERRUPT_f().

◆ DEBUG_PROCESS

#define DEBUG_PROCESS ( n)

◆ EXTRA_DEBUG

#define EXTRA_DEBUG   0

Definition at line 79 of file process.cc.

◆ MAX_PROCESS_STACK_SIZE

#define MAX_PROCESS_STACK_SIZE   1000000UL

This is theoretical max stack size for single SIMLIB Process at time of interruption (should never be too big, because of copying the stack contents) FIXME: should be checked at Process::Behavior interrupt for more precise error message.

Definition at line 358 of file process.cc.

Referenced by simlib3::restore_context().

◆ PROCESS_EXIT

#define PROCESS_EXIT ( )
Value:
static jmp_buf P_DispatcherStatusBuffer
setjmp() state before dispatch
Definition process.cc:68

does not save context

Definition at line 148 of file process.cc.

Referenced by simlib3::Process::Terminate().

◆ PROCESS_INTERRUPT

#define PROCESS_INTERRUPT ( )
Value:
{ \
\
this->_status = _INTERRUPTED; \
PROCESS_INTERRUPT_f(); \
this->_status = _RUNNING; \
this->_context = 0; \
}

interrupt process behavior execution, continue after return

Definition at line 138 of file process.cc.

Referenced by simlib3::Process::Activate(), simlib3::Process::Interrupt(), simlib3::Process::Passivate(), and simlib3::Process::Wait().

◆ STACK_RESERVED

#define STACK_RESERVED   0x080

Referenced by simlib3::Process::_Run().