reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
reactor_common.h
Go to the documentation of this file.
1
19
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
46#define MIN_SLEEP_DURATION USEC(10)
47
49
50// The following variables are defined in reactor_common.c and used in reactor.c,
51// reactor_threaded.c, modes.c, and by the code generator.
52extern bool _lf_normal_termination;
53extern unsigned int _lf_number_of_workers;
54extern int default_argc;
55extern const char** default_argv;
56extern instant_t duration;
57extern bool fast;
58extern bool keepalive_specified;
59
60#ifdef FEDERATED_DECENTRALIZED
62#endif
63
64// The following is defined by the code generator.
66
68
79
87
97void lf_free(struct allocation_record_t** head);
98
108
118
128
134
143
155
162
171void termination(void);
172
184void _lf_trigger_reaction(environment_t* env, reaction_t* reaction, int worker_number);
185
200
210
218
226
238
268
283
300trigger_handle_t _lf_schedule_copy(environment_t* env, void* action, interval_t offset, void* value, size_t length);
301
313
325
336
345void _lf_invoke_reaction(environment_t* env, reaction_t* reaction, int worker);
346
355void schedule_output_reactions(environment_t* env, reaction_t* reaction, int worker);
356
364int process_args(int argc, const char* argv[]);
365
372
373#endif
API for the environment data structure.
int64_t instant_t
Time instant.
Definition tag.h:101
int64_t interval_t
Interval of time.
Definition tag.h:107
void lf_recycle_event(environment_t *env, event_t *e)
Recycle the given event.
void _lf_trigger_shutdown_reactions(environment_t *env)
Trigger all the shutdown reactions in the specified environment.
void lf_set_default_command_line_options(void)
Generated function that optionally sets default command-line options.
int trigger_handle_t
Handles for scheduled triggers.
Definition lf_types.h:146
bool _lf_initialize_timers(environment_t *env)
Initialize all the timers in the environment.
void lf_replace_token(event_t *event, lf_token_t *token)
Replace the token on the specified event with the specified token and free the old token.
void _lf_pop_events(environment_t *env)
Pop all events from event_q with tag equal to current tag.
void initialize_global()
Initialize global variables and start tracing before calling the _lf_initialize_trigger_objects() fun...
pqueue_pri_t index_t
Topological order index for reactions.
Definition lf_types.h:166
void _lf_advance_tag(environment_t *env, tag_t next_tag)
Advance from the current tag to the next.
void _lf_initialize_trigger_objects()
Generated function that produces a table containing all triggers (i.e., inputs, timers,...
bool _lf_initialize_timer(environment_t *env, trigger_t *timer)
Initialize the given timer.
event_t * _lf_create_dummy_events(environment_t *env, tag_t tag)
Create a dummy event with the specified tag.
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.
trigger_handle_t _lf_schedule_token(environment_t *env, void *action, interval_t extra_delay, lf_token_t *token)
Schedule the specified action at a later tag with the specified token as a payload.
void _lf_invoke_reaction(environment_t *env, reaction_t *reaction, int worker)
Invoke the specified reaction on the specified worker in the specified environment.
int process_args(int argc, const char *argv[])
Process the command-line arguments.
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).
void lf_free(struct allocation_record_t **head)
Free memory on the specified allocation record (a self struct).
void termination(void)
Perform final wrap-up on exit.
void _lf_start_time_step(environment_t *env)
Perform whatever is needed to start a time step.
void lf_terminate_execution(environment_t *env)
Function that is called when the program is about to exit.
void schedule_output_reactions(environment_t *env, reaction_t *reaction, int worker)
Schedule the output reactions for the specified reaction in the specified environment.
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.
event_t * lf_get_new_event(environment_t *env)
Get a new event.
void lf_create_environments(void)
Create and initialize the required number of environments for the program.
trigger_handle_t _lf_schedule_copy(environment_t *env, void *action, interval_t offset, void *value, size_t length)
Schedule an action to occur with the specified value and time offset with a copy of the specified val...
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.
void _lf_trigger_startup_reactions(environment_t *env)
Trigger all the startup reactions in the specified environment.
Type definitions that are widely used across different parts of the runtime.
Header file of the runtime infrastructure for modes in the C target of Lingua Franca.
Support for optimizing sparse input through multiports.
Priority queue definitions for queues where the priority is a number that can be compared with ordina...
unsigned int _lf_number_of_workers
interval_t lf_fed_STA_offset
bool _lf_normal_termination
bool keepalive_specified
instant_t duration
bool fast
int default_argc
const char ** default_argv
struct allocation_record_t * _lf_reactors_to_free
Allocation record to keep track of dynamically-allocated memory.
Definition lf_types.h:499
Execution environment.
Definition environment.h:52
Event activation record to push onto the event queue.
Definition lf_types.h:354
Token type for dynamically allocated arrays and structs sent as messages.
Definition lf_token.h:99
Reaction activation record to push onto the reaction queue.
Definition lf_types.h:195
A tag is a time, microstep pair.
Definition tag.h:119
Trigger struct representing an output, timer, action, or input.
Definition lf_types.h:391
Time and tag definitions and functions for Lingua Franca.
Core utility functions for Lingua Franca.