The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
process.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <stdbool.h>
36 
37 #include <mm/state.h>
38 #include <mm/mm.h>
39 #include <mm/ecs.h>
40 #include <datatypes/list.h>
41 #include <datatypes/msgchannel.h>
42 #include <arch/ult.h>
43 #include <lib/numerical.h>
44 #include <lib/abm_layer.h>
45 #include <lib/topology.h>
48 
49 #define LP_STACK_SIZE 4194304 // 4 MB
50 
51 #define LP_STATE_READY 0x00001
52 #define LP_STATE_RUNNING 0x00002
53 #define LP_STATE_RUNNING_ECS 0x00004
54 #define LP_STATE_ROLLBACK 0x00008
55 #define LP_STATE_SILENT_EXEC 0x00010
56 #define LP_STATE_SUSPENDED 0x01010
57 #define LP_STATE_READY_FOR_SYNCH 0x00011 // This should be a blocked state! Check schedule() and stf()
58 #define LP_STATE_WAIT_FOR_SYNCH 0x01001
59 #define LP_STATE_WAIT_FOR_UNBLOCK 0x01002
60 #define LP_STATE_WAIT_FOR_DATA 0x01004
61 
62 #define BLOCKED_STATE 0x01000
63 #define is_blocked_state(state) (bool)(state & BLOCKED_STATE)
64 
65 struct lp_struct {
68 
71 
73  void *stack;
74 
76  struct memory_map *mm;
77 
80 
83 
85  unsigned int worker_thread;
86 
88  short unsigned int state;
89 
91  unsigned int ckpt_period;
92 
94  unsigned int from_last_ckpt;
95 
98 
101 
103  list(msg_t) queue_in;
104 
107 
109  list(msg_hdr_t) queue_out;
110 
112  list(state_t) queue_states;
113 
116 
118  list(msg_t) rendezvous_queue;
119 
121  unsigned long long mark;
122 
125 
130  bool (*OnGVT)(unsigned int me, void *snapshot);
131 
136  void (*ProcessEvent)(unsigned int me, simtime_t now, int event_type,
137  void *event_content, unsigned int size,
138  void *state);
139 
140 #ifdef HAVE_CROSS_STATE
141  GID_t ECS_synch_table[MAX_CROSS_STATE_DEPENDENCIES];
142  unsigned int ECS_index;
143 #endif
144 
145  unsigned long long wait_on_rendezvous;
146  unsigned int wait_on_object;
147 
148  /* Per-Library variables */
149  numerical_state_t numerical;
150 
153 
156 
157 };
158 
159 // LPs process control blocks and binding control blocks
160 extern struct lp_struct **lps_blocks;
161 extern __thread struct lp_struct **lps_bound_blocks;
162 
168 #define lvt(lp) (lp->bound != NULL ? lp->bound->timestamp : 0.0)
169 
170 // TODO: see issue #121 to see how to make this ugly hack disappear
171 extern __thread unsigned int __lp_counter;
172 extern __thread unsigned int __lp_bound_counter;
173 
174 #define foreach_lp(lp) __lp_counter = 0;\
175  for(struct lp_struct *(lp) = lps_blocks[__lp_counter]; __lp_counter < n_prc && ((lp) = lps_blocks[__lp_counter]); ++__lp_counter)
176 
177 #define foreach_bound_lp(lp) __lp_bound_counter = 0;\
178  for(struct lp_struct *(lp) = lps_bound_blocks[__lp_bound_counter]; __lp_bound_counter < n_prc_per_thread && ((lp) = lps_bound_blocks[__lp_bound_counter]); ++__lp_bound_counter)
179 
180 #define LPS_bound_set(entry, lp) lps_bound_blocks[(entry)] = (lp);
181 
182 extern void initialize_binding_blocks(void);
183 extern void initialize_lps(void);
184 extern struct lp_struct *find_lp_by_gid(GID_t);
Per-thread page table.
Definition of a LID.
Definition: core.h:144
Communication Routines.
msg_t * bound
Pointer to the last correctly processed event.
Definition: process.h:106
Structure for LP&#39;s state.
Definition: state.h:49
User-Level Threads Headers.
A (M, 1) channel for messages.
Definition: mm.h:77
msg_channel * bottom_halves
Bottom halves.
Definition: process.h:115
void * stack
Process&#39; stack.
Definition: process.h:73
bool state_log_forced
If this variable is set, the next invocation to LogState() takes a new state log, independently of th...
Definition: process.h:97
struct memory_map * mm
Memory map of the LP.
Definition: process.h:76
Numerical Library.
double simtime_t
This defines the type with whom timestamps are represented.
Definition: ROOT-Sim.h:55
unsigned int from_last_ckpt
Counts how many events executed from the last checkpoint (to support PSS)
Definition: process.h:94
Memory Manager main header.
topology_t * topology
pointer to the topology struct
Definition: process.h:152
unsigned long long mark
Unique identifier within the LP.
Definition: process.h:121
Generic Lists.
Message Type definition.
Definition: core.h:164
bool(* OnGVT)(unsigned int me, void *snapshot)
Definition: process.h:130
list(msg_t) queue_in
Input messages queue.
Definition of a GID.
Definition: core.h:132
outgoing_t outgoing_buffer
Buffer used by KLTs for buffering outgoing messages during the execution of an event.
Definition: process.h:124
region_abm_t * region
pointer to the region struct
Definition: process.h:155
GID_t gid
Global ID of the LP.
Definition: process.h:82
short unsigned int state
Current execution state of the LP.
Definition: process.h:88
LP state management.
LP_context_t context
LP execution state.
Definition: process.h:67
struct lp_struct ** lps_blocks
Maintain LPs&#39; simulation and execution states.
Definition: process.c:44
__thread struct lp_struct ** lps_bound_blocks
Definition: process.c:49
LP_context_t default_context
LP execution state when blocked during the execution of an event.
Definition: process.h:70
void(* ProcessEvent)(unsigned int me, simtime_t now, int event_type, void *event_content, unsigned int size, void *state)
Definition: process.h:136
LID_t lid
Local ID of the LP.
Definition: process.h:79
Message envelope definition. This is used to handle the output queue and stores information needed to...
Definition: core.h:194
Per-LP buffer of newly-generated events.
Event & Cross State Synchornization.
unsigned int ckpt_period
This variable mainains the current checkpointing interval for the LP.
Definition: process.h:91
void * current_base_pointer
The current state base pointer (updated by SetState())
Definition: process.h:100
unsigned int worker_thread
ID of the worker thread towards which the LP is bound.
Definition: process.h:85
the customised struct for TOPOLOGY_OBSTACLES representation
Definition: costs.c:22
This structure describes the CPU context of a User-Level Thread.
Definition: jmp.h:42