The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
scheduler.h File Reference

The ROOT-Sim scheduler main module header. More...

#include <ROOT-Sim.h>
#include <core/core.h>
#include <queues/queues.h>
#include <communication/communication.h>
#include <scheduler/stf.h>
#include <arch/ult.h>
#include <scheduler/process.h>
+ Include dependency graph for scheduler.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _SCHEDULER_H_
 
#define MAX_CONSECUTIVE_IDLE_CYCLES   1000
 This macro defines after how many idle cycles the simulation is stopped.
 
#define switch_to_platform_mode()
 
#define switch_to_application_mode()   platform_mode = false
 

Enumerations

enum  { SCHEDULER_INVALID = 0, SCHEDULER_STF }
 

Functions

void scheduler_init (void)
 
void scheduler_fini (void)
 
void schedule (void)
 
void schedule_on_init (struct lp_struct *next)
 
void initialize_worker_thread (void)
 
void activate_LP (struct lp_struct *, msg_t *)
 
void LP_main_loop (void *args)
 
bool receive_control_msg (msg_t *)
 
bool process_control_msg (msg_t *)
 
bool reprocess_control_msg (msg_t *)
 
void rollback_control_message (struct lp_struct *current, simtime_t)
 
bool anti_control_message (msg_t *msg)
 
void preempt_init (void)
 
void preempt_fini (void)
 
void reset_min_in_transit (unsigned int)
 
void update_min_in_transit (unsigned int, simtime_t)
 
void enable_preemption (void)
 
void disable_preemption (void)
 

Variables

__thread struct lp_structcurrent
 This is a per-thread variable pointing to the block state of the LP currently scheduled.
 
__thread msg_tcurrent_evt
 
__thread unsigned int n_prc_per_thread
 This is used to keep track of how many LPs were bound to the current KLT.
 
__thread volatile bool platform_mode
 

Detailed Description

The ROOT-Sim scheduler main module header.

This module implements the schedule() function, which is the main entry point for all the schedulers implemented in ROOT-Sim, and several support functions which allow to initialize worker threads.

Also, the LP_main_loop() function, which is the function where all the User-Level Threads associated with Logical Processes live, is defined here.

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Francesco Quaglia
Alessandro Pellegrini
Roberto Vitali

Definition in file scheduler.h.

Macro Definition Documentation

#define switch_to_platform_mode ( )
Value:
do {\
if(current->state != LP_STATE_SILENT_EXEC) {\
platform_mode = true;\
}\
} while(0)
__thread struct lp_struct * current
This is a per-thread variable pointing to the block state of the LP currently scheduled.
Definition: scheduler.c:72
short unsigned int state
Current execution state of the LP.
Definition: process.h:88

Definition at line 87 of file scheduler.h.

Enumeration Type Documentation

anonymous enum
Enumerator
SCHEDULER_INVALID 

By convention 0 is the invalid field

SCHEDULER_STF 

Smallest Timestamp First Scheduler's Code

Definition at line 52 of file scheduler.h.

Function Documentation

void activate_LP ( struct lp_struct next,
msg_t evt 
)

This function is the application-level ProcessEvent() callback entry point. It allows to specify which lp must be scheduled, specifying its lvt, its event to be executed and its simulation state. This provides a general entry point to application-level code, to be used if the LP is in forward execution, in coasting forward or in initialization.

Author
Alessandro Pellegrini
Date
November 11, 2013
Parameters
nextA pointer to the lp_struct of the LP which has to be activated
evtA pointer to the event to be processed by the LP

Definition at line 260 of file scheduler.c.

+ Here is the caller graph for this function:

void LP_main_loop ( void *  args)

This is a LP main loop. It s the embodiment of the usrespace thread implementing the logic of the LP. Whenever an event is to be scheduled, the corresponding metadata are set by the schedule() function, which in turns calls activate_LP() to execute the actual context switch. This ProcessEvent wrapper explicitly returns control to simulation kernel user thread when an event processing is finished. In case the LP tries to access state data which is not belonging to its simulation state, a SIGSEGV signal is raised and the LP might be descheduled if it is not safe to perform the remote memory access. This is the only case where control is not returned to simulation thread explicitly by this wrapper.

Parameters
argsarguments passed to the LP main loop. Currently, this is not used.

Definition at line 140 of file scheduler.c.

+ Here is the call graph for this function:

void schedule ( void  )

This function checks wihch LP must be activated (if any), and in turn activates it. This is used only to support forward execution.

Author
Alessandro Pellegrini

Definition at line 321 of file scheduler.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void scheduler_fini ( void  )

This function finalizes the scheduler

Author
Alessandro Pellegrini

Definition at line 105 of file scheduler.c.

+ Here is the caller graph for this function:

Variable Documentation

__thread msg_t* current_evt

This is a per-thread variable telling what is the event that should be executed when activating an LP. It is incorrect to rely on current->bound, as there are cases (such as the silent execution) in which we have a certain bound set, but we execute a different event.

Definition at line 83 of file scheduler.c.