reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
reactor_common.h
Go to the documentation of this file.
1
20#ifndef REACTOR_COMMON_H
21#define REACTOR_COMMON_H
22
23#include "lf_types.h"
24#include "environment.h"
25#include "tag.h"
26#include "pqueue.h"
27#include "vector.h"
28#include "util.h"
29#include "modes.h"
30#include "port.h"
31
33
45#define MIN_SLEEP_DURATION USEC(10)
46
48
49// The following variables are defined in reactor_common.c and used in reactor.c,
50// reactor_threaded.c, modes.c, and by the code generator.
51extern bool _lf_normal_termination;
52extern unsigned int _lf_number_of_workers;
53extern int default_argc;
54extern const char** default_argv;
55extern instant_t duration;
56extern bool fast;
57extern bool keepalive_specified;
58
59#ifdef FEDERATED_DECENTRALIZED
60extern interval_t lf_fed_STA_offset;
61#endif
62
63// The following is defined by the code generator.
65
67
77
83
92void lf_free(struct allocation_record_t** head);
93
100
109
116void lf_replace_token(event_t* event, lf_token_t* token);
117
122
131
142
148
156void termination(void);
157
167void _lf_trigger_reaction(environment_t* env, reaction_t* reaction, int worker_number);
168
178
184
190
196
207
236
246
254void _lf_advance_tag(environment_t* env, tag_t next_tag);
255
265
266void _lf_invoke_reaction(environment_t* env, reaction_t* reaction, int worker);
268int process_args(int argc, const char* argv[]);
269
273void initialize_global();
274
275#endif
API for the environment data structure.
Type definitions that are widely used across different parts of the runtime.
int trigger_handle_t
Definition lf_types.h:117
pqueue_pri_t index_t
Definition lf_types.h:132
Priority queue definitions for queues where the priority is a number that can be compared with ordina...
unsigned int _lf_number_of_workers
Definition reactor_common.c:78
void lf_recycle_event(environment_t *env, event_t *e)
Recycle the given event.
Definition reactor_common.c:454
void _lf_trigger_shutdown_reactions(environment_t *env)
Trigger all the shutdown reactions in the specified environment.
Definition reactor_common.c:436
void lf_set_default_command_line_options(void)
Generated function that optionally sets default command-line options.
Definition src_gen_stub.c:16
bool _lf_normal_termination
Definition reactor_common.c:1126
void lf_replace_token(event_t *event, lf_token_t *token)
Definition reactor_common.c:473
bool keepalive_specified
Definition reactor_common.c:88
void _lf_pop_events(environment_t *env)
Pop all events from event_q with tag equal to current tag.
Definition reactor_common.c:229
void initialize_global()
Initialize global variables and start tracing before calling the _lf_initialize_trigger_objects funct...
Definition reactor_common.c:1081
void _lf_advance_tag(environment_t *env, tag_t next_tag)
Definition reactor_common.c:642
void _lf_initialize_trigger_objects()
Definition src_gen_stub.c:14
void _lf_initialize_timers(environment_t *env)
Initialize all the timers in the environment.
Definition reactor_common.c:401
event_t * _lf_create_dummy_events(environment_t *env, tag_t tag)
Create a dummy event with the specified tag.
Definition reactor_common.c:465
void _lf_initialize_timer(environment_t *env, trigger_t *timer)
Initialize the given timer. If this timer has a zero offset, enqueue the reactions it triggers....
Definition reactor_common.c:354
index_t lf_combine_deadline_and_level(interval_t deadline, int level)
Combine a deadline and a level into a single index for sorting in the reaction queue.
Definition reactor_common.c:1224
void _lf_invoke_reaction(environment_t *env, reaction_t *reaction, int worker)
Definition reactor_common.c:684
instant_t duration
Definition reactor_common.c:85
int process_args(int argc, const char *argv[])
Definition reactor_common.c:910
bool fast
Definition reactor_common.c:68
trigger_handle_t _lf_schedule_at_tag(environment_t *env, trigger_t *trigger, tag_t tag, lf_token_t *token)
Schedule an event at a specific tag (time, microstep).
Definition reactor_common.c:482
void lf_free(struct allocation_record_t **head)
Free memory on the specified allocation record (a self struct).
Definition reactor_common.c:114
void termination(void)
Perform final wrap-up on exit.
Definition reactor_common.c:1132
int default_argc
Definition reactor_common.c:901
void _lf_start_time_step(environment_t *env)
Perform whatever is needed to start a time step.
Definition reactor_common.c:164
const char ** default_argv
Definition reactor_common.c:902
void schedule_output_reactions(environment_t *env, reaction_t *reaction, int worker)
Definition reactor_common.c:715
trigger_handle_t _lf_insert_reactions_for_trigger(environment_t *env, trigger_t *trigger, lf_token_t *token)
Insert reactions triggered by trigger to the reaction queue.
Definition reactor_common.c:562
event_t * lf_get_new_event(environment_t *env)
Definition reactor_common.c:339
void lf_create_environments(void)
Create and initialize the required number of environments for the program.
void _lf_trigger_reaction(environment_t *env, reaction_t *reaction, int worker_number)
Trigger the specified reaction on the specified worker in the specified environment.
Definition reactor_threaded.c:532
struct allocation_record_t * _lf_reactors_to_free
Definition reactor_common.c:110
void _lf_trigger_startup_reactions(environment_t *env)
Trigger all the startup reactions in the specified environment.
Definition reactor_common.c:417
void * worker(void *arg)
Definition reactor_threaded.c:875
void lf_terminate_execution(void)
Definition src_gen_stub.c:15
Definition lf_types.h:257
Execution environment. This struct contains information about the execution environment....
Definition environment.h:49
Definition lf_types.h:196
Definition lf_token.h:94
Definition lf_types.h:155
Definition tag.h:81
Definition lf_types.h:208
Time and tag definitions and functions for Lingua Franca.
int64_t instant_t
Definition tag.h:66
int64_t interval_t
Definition tag.h:71