The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
scheduler.h
Go to the documentation of this file.
1 
37 #pragma once
38 #ifndef _SCHEDULER_H_
39 #define _SCHEDULER_H_
40 
41 #include <ROOT-Sim.h>
42 #include <core/core.h>
43 #include <queues/queues.h>
45 #include <scheduler/stf.h>
46 #include <arch/ult.h>
47 #include <scheduler/process.h>
48 
50 #define MAX_CONSECUTIVE_IDLE_CYCLES 1000
51 
52 enum {
55 };
56 
57 /* Functions invoked by other modules */
58 extern void scheduler_init(void);
59 extern void scheduler_fini(void);
60 extern void schedule(void);
61 extern void schedule_on_init(struct lp_struct *next);
62 extern void initialize_worker_thread(void);
63 extern void activate_LP(struct lp_struct *, msg_t *);
64 extern void LP_main_loop(void *args);
65 
66 extern bool receive_control_msg(msg_t *);
67 extern bool process_control_msg(msg_t *);
68 extern bool reprocess_control_msg(msg_t *);
69 extern void rollback_control_message(struct lp_struct *current, simtime_t);
70 extern bool anti_control_message(msg_t * msg);
71 
72 #ifdef HAVE_PREEMPTION
73 extern void preempt_init(void);
74 extern void preempt_fini(void);
75 extern void reset_min_in_transit(unsigned int);
76 extern void update_min_in_transit(unsigned int, simtime_t);
77 void enable_preemption(void);
78 void disable_preemption(void);
79 #endif
80 
81 extern __thread struct lp_struct *current;
82 extern __thread msg_t *current_evt;
83 extern __thread unsigned int n_prc_per_thread;
84 
85 #ifdef HAVE_PREEMPTION
86 extern __thread volatile bool platform_mode;
87 #define switch_to_platform_mode() do {\
88  if(current->state != LP_STATE_SILENT_EXEC) {\
89  platform_mode = true;\
90  }\
91  } while(0)
92 
93 #define switch_to_application_mode() platform_mode = false
94 #else
95 #define switch_to_platform_mode() {}
96 #define switch_to_application_mode() {}
97 #endif /* HAVE_PREEMPTION */
98 
99 #endif
Communication Routines.
void activate_LP(struct lp_struct *, msg_t *)
Definition: scheduler.c:260
Message queueing subsystem.
User-Level Threads Headers.
Core ROOT-Sim functionalities.
ROOT-Sim header for model development.
__thread msg_t * current_evt
Definition: scheduler.c:83
__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 LP_main_loop(void *args)
Definition: scheduler.c:140
__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
double simtime_t
This defines the type with whom timestamps are represented.
Definition: ROOT-Sim.h:55
Message Type definition.
Definition: core.h:164
void scheduler_fini(void)
Definition: scheduler.c:105
LP control blocks.
O(n) scheduling algorithm.
void schedule(void)
Definition: scheduler.c:321