The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
fossil.c
Go to the documentation of this file.
1 
31 #include <arch/thread.h>
32 #include <core/init.h>
33 #include <gvt/gvt.h>
34 #include <gvt/ccgs.h>
35 #include <mm/state.h>
36 #include <mm/mm.h>
37 #include <scheduler/process.h>
38 #include <scheduler/scheduler.h>
39 #include <statistics/statistics.h>
40 
42 static unsigned long long snapshot_cycles;
43 
53 void fossil_collection(struct lp_struct *lp, simtime_t time_barrier)
54 {
55  state_t *state;
56  msg_t *last_kept_event;
57  double committed_events;
58 
59  // State list must be handled specifically, as nodes point to malloc'd
60  // nodes. We therefore manually scan the list and free the memory.
61  while ((state = list_head(lp->queue_states)) != NULL
62  && state->lvt < time_barrier) {
63  log_delete(state->log);
64  if(&topology_settings && topology_settings.write_enabled)
65  rsfree(state->topology);
66  if(&abm_settings)
67  rsfree(state->region_data);
68 #ifndef NDEBUG
69  state->last_event = (void *)0xDEADBABE;
70 #endif
71  list_pop(lp->queue_states);
72  }
73 
74  // Determine queue pruning horizon
75  state = list_head(lp->queue_states);
76  last_kept_event = state->last_event;
77 
78  // Truncate the input queue, accounting for the event which is pointed by the lastly kept state
79  committed_events =
80  (double)list_trunc(lp->queue_in, timestamp,
81  last_kept_event->timestamp, msg_release);
82  statistics_post_data(lp, STAT_COMMITTED, committed_events);
83 
84  // Truncate the output queue
85  list_trunc(lp->queue_out, send_time, last_kept_event->timestamp,
87 }
88 
96 void adopt_new_gvt(simtime_t new_gvt)
97 {
98  unsigned int i;
99 
100  state_t *time_barrier_pointer[n_prc_per_thread];
101  bool compute_snapshot;
102 
103  // Snapshot should be recomputed only periodically
104  snapshot_cycles++;
105  compute_snapshot =
107 
108  // Precompute the time barrier for each process
109  i = 0;
110  foreach_bound_lp(lp) {
111  time_barrier_pointer[i++] = find_time_barrier(lp, new_gvt);
112  }
113 
114  // If needed, call the CCGS subsystem
115  if (compute_snapshot)
116  ccgs_compute_snapshot(time_barrier_pointer, new_gvt);
117 
118  i = 0;
119  foreach_bound_lp(lp) {
120  if (time_barrier_pointer[i] == NULL)
121  continue;
122 
123  // Execute the fossil collection
124  fossil_collection(lp, time_barrier_pointer[i]->lvt);
125 
126  // Actually release memory buffer allocated by the LPs and then released via free() calls
127  clean_buffers_on_gvt(lp, time_barrier_pointer[i]->lvt);
128 
129  i++;
130  }
131 }
#define lvt(lp)
Definition: process.h:168
Initialization routines.
Structure for LP&#39;s state.
Definition: state.h:49
void log_delete(void *ckpt)
Definition: checkpoints.c:374
simtime_t lvt
Simulation time associated with the state log.
Definition: state.h:55
Statistics module.
The ROOT-Sim scheduler main module header.
Generic thread management facilities.
Consistent and Committed Global State.
#define list_trunc(list, key_name, key_value, release_fn)
Truncate a list up to a certain point, starting from the head.
Definition: list.h:268
double simtime_t
This defines the type with whom timestamps are represented.
Definition: ROOT-Sim.h:55
simulation_configuration rootsim_config
This global variable holds the configuration for the current simulation.
Definition: core.c:70
Memory Manager main header.
Message Type definition.
Definition: core.h:164
msg_t * last_event
This log has been taken after the execution of this event.
Definition: state.h:59
void * log
A pointer to the actual log.
Definition: state.h:57
LP control blocks.
#define list_head(list)
Definition: list.h:74
void msg_release(msg_t *msg)
Release a message buffer.
state_t * find_time_barrier(struct lp_struct *lp, simtime_t simtime)
Definition: state.c:282
LP state management.
void ccgs_compute_snapshot(state_t *time_barrier_pointer[], simtime_t gvt)
Definition: ccgs.c:107
Global Virtual Time.
void msg_hdr_release(msg_hdr_t *msg)
Release a message header.
void adopt_new_gvt(simtime_t new_gvt)
Definition: fossil.c:96
__thread unsigned int n_prc_per_thread
This is used to keep track of how many LPs were bound to the current KLT.
Definition: scheduler.c:69
static unsigned long long snapshot_cycles
Counter for the invocations of adopt_new_gvt. This is used to determine whether a consistent state mu...
Definition: fossil.c:42
void fossil_collection(struct lp_struct *lp, simtime_t time_barrier)
Definition: fossil.c:53
int gvt_snapshot_cycles
GVT operations to be executed before rebuilding the state.
Definition: init.h:61