The ROme OpTimistic Simulator
2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
Main Page
Data Structures
Files
File List
Globals
ult.h
Go to the documentation of this file.
1
40
#pragma once
41
42
#include <
core/core.h
>
43
44
#if defined(OS_LINUX)
45
46
#if !defined(__x86_64__)
47
#error Unsupported architecture
48
#endif
49
50
#include <
arch/jmp.h
>
51
53
typedef
exec_context_t
LP_context_t
;
54
56
typedef
exec_context_t
kernel_context_t
;
57
69
#define context_save(context) set_jmp(context)
70
72
#define context_restore(context) long_jmp(context, 1)
73
75
#define context_switch(context_old, context_new) \
76
if(set_jmp(context_old) == 0) \
77
long_jmp(context_new, (context_new)->rax)
78
80
#define context_switch_create(context_old, context_new) \
81
if(set_jmp(context_old) == 0) \
82
long_jmp(context_new, 1)
83
84
extern
void
*
get_ult_stack
(
size_t
size);
85
86
#elif defined(OS_CYGWIN) || defined(OS_WINDOWS)
87
88
#include <windows.h>
89
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400
90
# if defined(__MINGW32__)
91
# include <w32api.h>
92
# if __W32API_MAJOR_VERSION > 3 || __W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 6
93
# define _WIN32_XP
94
# endif
95
# else
96
# define _WIN32_XP
97
# endif
98
#endif
99
101
struct
__execution_context_t {
102
void
*jb;
103
};
104
105
typedef
struct
__execution_context_t
LP_context_t
;
106
typedef
struct
__execution_context_t
kernel_context_t
;
107
109
#define context_switch(context_old, context_new) \
110
do { \
111
(void)context_old.jb; \
112
SwitchToFiber(context_new.jb); \
113
} while (0)
114
115
// On Windows/Cygwin we use fibers, so there is no need to allocate LP's stacks
116
#define get_ult_stack(lid, size) NULL
117
#define context_save(context) {}
118
#define context_restore(context) {}
119
120
// This is a function which creates a new fiber when running on Windows
121
extern
void
context_create
(
LP_context_t
* context,
void
(*entry_point)(
void
*),
void
*args,
void
*stack,
size_t
stack_size);
122
123
#endif
/* OS */
124
125
// This is the current KLT main execution context
126
extern
__thread
kernel_context_t
kernel_context
;
context_create
void context_create(exec_context_t *creat, void(*fn)(void *), void *args, void *stack, size_t stack_size)
core.h
Core ROOT-Sim functionalities.
jmp.h
Architecture-independent ULT header.
get_ult_stack
void * get_ult_stack(size_t size)
Definition:
ult.c:65
kernel_context
__thread kernel_context_t kernel_context
This is the execution context of the simulation kernel.
Definition:
ult.c:51
kernel_context_t
exec_context_t kernel_context_t
Definition of an execution context for a worker thread. This is just syntactic sugar.
Definition:
ult.h:56
LP_context_t
exec_context_t LP_context_t
Definition of an execution context for an LP. This is just syntactic sugar.
Definition:
ult.h:53
__exec_context_t
This structure describes the CPU context of a User-Level Thread.
Definition:
jmp.h:42
src
arch
ult.h
Generated by
1.8.11