55 #ifdef HAVE_CROSS_STATE 93 void scheduler_init(
void)
95 #ifdef HAVE_PREEMPTION 107 #ifdef HAVE_PREEMPTION 112 rsfree(lp->queue_in);
113 rsfree(lp->queue_out);
114 rsfree(lp->queue_states);
115 rsfree(lp->bottom_halves);
116 rsfree(lp->rendezvous_queue);
143 unsigned long long hash1, hash2;
161 timer_start(event_timer);
166 }
else if (&topology_settings){
167 ProcessEventTopology();
169 switch_to_application_mode();
175 switch_to_platform_mode();
177 int delta_event_timer = timer_value_micro(event_timer);
186 if (hash1 != hash2) {
188 "Error, LP %d has modified the payload of event %d during its processing. Aborting...\n",
189 current->
gid, current->
bound->type);
193 statistics_post_data(current, STAT_EVENT, 1.0);
194 statistics_post_data(current, STAT_EVENT_TIME,
202 void initialize_worker_thread(
void)
209 printf(
"Initializing LPs... ");
223 foreach_bound_lp(lp) {
224 pack_msg(&init_event, lp->gid, lp->gid,
INIT, 0.0, 0.0, 0, NULL);
226 list_insert_head(lp->queue_in, init_event);
227 lp->state_log_forced =
true;
232 foreach_bound_lp(lp) {
233 schedule_on_init(lp);
239 #ifdef HAVE_PREEMPTION 272 #ifdef HAVE_CROSS_STATE 278 rootsim_error(
true,
"Critical condition: LP %d has a wrong state: %d. Aborting...\n",
289 #ifdef HAVE_CROSS_STATE 291 if (!is_blocked_state(next->
state)) {
293 lp_alloc_deschedule();
300 bool check_rendevouz_request(
struct lp_struct *lp)
304 if (lp->
state != LP_STATE_WAIT_FOR_SYNCH)
326 #ifdef HAVE_CROSS_STATE 327 bool resume_execution =
false;
338 rootsim_error(
true,
"unrecognized scheduler!");
343 statistics_post_data(NULL, STAT_IDLE_CYCLES, 1.0);
347 if (next->
state == LP_STATE_ROLLBACK) {
349 next->
state = LP_STATE_READY;
354 if (!is_blocked_state(next->
state)
355 && next->
state != LP_STATE_READY_FOR_SYNCH) {
367 "Critical condition: LP %d seems to have events to be processed, but I cannot find them. Aborting...\n",
371 if (
unlikely(!process_control_msg(event))) {
374 #ifdef HAVE_CROSS_STATE 377 if (is_blocked_state(next->
state) || next->
state == LP_STATE_READY_FOR_SYNCH) {
378 resume_execution =
true;
383 if (next->
state == LP_STATE_READY_FOR_SYNCH)
384 next->
state = LP_STATE_RUNNING_ECS;
386 next->
state = LP_STATE_RUNNING;
390 if (!is_blocked_state(next->
state)) {
391 next->
state = LP_STATE_READY;
394 #ifdef HAVE_CROSS_STATE 395 if (resume_execution && !is_blocked_state(next->
state)) {
398 unblock_synchronized_objects(next);
409 void schedule_on_init(
struct lp_struct *next)
413 #ifdef HAVE_CROSS_STATE 414 bool resume_execution =
false;
427 "Critical condition: LP %d should have an INIT event but I cannot find it. Aborting...\n",
431 #ifdef HAVE_CROSS_STATE 434 if (is_blocked_state(next->
state) || next->
state == LP_STATE_READY_FOR_SYNCH) {
435 resume_execution =
true;
439 next->
state = LP_STATE_RUNNING;
443 if (!is_blocked_state(next->
state)) {
444 next->
state = LP_STATE_READY;
447 #ifdef HAVE_CROSS_STATE 448 if (resume_execution && !is_blocked_state(next->
state)) {
451 unblock_synchronized_objects(next);
void scheduler_fini(void)
msg_t * bound
Pointer to the last correctly processed event.
unsigned long long generate_mark(struct lp_struct *lp)
void force_LP_checkpoint(struct lp_struct *lp)
struct lp_struct * smallest_timestamp_first(void)
O(n) scheduler.
#define context_switch(context_old, context_new)
Swicth machine context for userspace context switch. This is used to schedule a LP or return control ...
void ProcessEventABM(void)
struct lp_struct ** lps_blocks
Maintain LPs' simulation and execution states.
User-Level Threads Headers.
A (M, 1) channel for messages.
Core ROOT-Sim functionalities.
unsigned int to_int
The GID numerical value.
The ROOT-Sim scheduler main module header.
Load sharing rules across worker threads.
Generic thread management facilities.
__thread struct lp_struct * current
This is a per-thread variable pointing to the block state of the LP currently scheduled.
ECS protocol: start synchronizing two LPs for a page fault.
int scheduler
Which scheduler to be used.
void LP_main_loop(void *args)
simulation_configuration rootsim_config
This global variable holds the configuration for the current simulation.
__thread msg_t * current_evt
Memory Manager main header.
unsigned int size
Unique identifier of the message, used for rendez-vous events.
void rollback(struct lp_struct *lp)
__thread struct lp_struct ** lps_bound_blocks
bool thread_barrier(barrier_t *b)
__thread kernel_context_t kernel_context
This is the execution context of the simulation kernel.
void activate_LP(struct lp_struct *next, msg_t *evt)
unsigned long long rendezvous_mark
Unique identifier of the message, used for antimessages.
void pack_msg(msg_t **msg, GID_t sender, GID_t receiver, int type, simtime_t timestamp, simtime_t send_time, size_t size, void *payload)
Pack a message in a platform-level data structure.
barrier_t all_thread_barrier
Barrier for all worker threads.
#define master_thread()
This macro expands to true if the current KLT is the master thread for the local kernel.
GID_t gid
Global ID of the LP.
short unsigned int state
Current execution state of the LP.
#define master_kernel()
This macro expands to true if the local kernel is the master kernel.
LP_context_t context
LP execution state.
O(n) scheduling algorithm.
LP_context_t default_context
LP execution state when blocked during the execution of an event.
void(* ProcessEvent)(unsigned int me, simtime_t now, int event_type, void *event_content, unsigned int size, void *state)
msg_t * advance_to_next_event(struct lp_struct *lp)
__thread unsigned int n_prc_per_thread
This is used to keep track of how many LPs were bound to the current KLT.
#define INIT
This is the message code which is sent by the simulation kernel upon startup.
#define context_save(context)
Save machine context for userspace context switch.
Event & Cross State Synchornization.
void * current_base_pointer
The current state base pointer (updated by SetState())
bool disable_preemption
If compiled for preemptive Time Warp, it can be disabled at runtime.
#define unlikely(exp)
Optimize the branch as likely not taken.
bool LogState(struct lp_struct *lp)
void send_outgoing_msgs(struct lp_struct *lp)
Send all pending outgoing messages.