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 
50 void fossil_collection(struct lp_struct *lp, simtime_t time_barrier)
51 {
52  state_t *state;
53  msg_t *last_kept_event;
54  double committed_events;
55 
56  // State list must be handled specifically, as nodes point to malloc'd
57  // nodes. We therefore manually scan the list and free the memory.
58  while ((state = list_head(lp->queue_states)) != NULL
59  && state->lvt < time_barrier) {
60  log_delete(state->log);
61  if(&topology_settings && topology_settings.write_enabled)
62  rsfree(state->topology);
63  if(&abm_settings)
64  rsfree(state->region_data);
65 #ifndef NDEBUG
66  state->last_event = (void *)0xDEADBABE;
67 #endif
68  list_pop(lp->queue_states);
69  }
70 
71  // Determine queue pruning horizon
72  state = list_head(lp->queue_states);
73  last_kept_event = state->last_event;
74 
75  // Truncate the input queue, accounting for the event which is pointed by the lastly kept state
76  committed_events =
77  (double)list_trunc(lp->queue_in, timestamp,
78  last_kept_event->timestamp, msg_release);
79  statistics_post_data(lp, STAT_COMMITTED, committed_events);
80 
81  // Truncate the output queue
82  list_trunc(lp->queue_out, send_time, last_kept_event->timestamp,
84 }
85 
93 void adopt_new_gvt(simtime_t new_gvt)
94 {
95  unsigned int i;
96 
97  state_t *time_barrier_pointer[n_prc_per_thread];
98 
99  // Precompute the time barrier for each process
100  i = 0;
101  foreach_bound_lp(lp) {
102  time_barrier_pointer[i++] = find_time_barrier(lp, new_gvt);
103  }
104 
105  // If needed, call the CCGS subsystem
106  ccgs_compute_snapshot(time_barrier_pointer);
107 
108  i = 0;
109  foreach_bound_lp(lp) {
110  if (time_barrier_pointer[i] == NULL)
111  continue;
112 
113  // Execute the fossil collection
114  fossil_collection(lp, time_barrier_pointer[i]->lvt);
115 
116  // Actually release memory buffer allocated by the LPs and then released via free() calls
117  clean_buffers_on_gvt(lp, time_barrier_pointer[i]->lvt);
118 
119  i++;
120  }
121 }
#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:371
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:56
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
void ccgs_compute_snapshot(state_t *time_barrier_pointer[])
Definition: ccgs.c:107
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:284
LP state management.
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:93
__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
void fossil_collection(struct lp_struct *lp, simtime_t time_barrier)
Definition: fossil.c:50