reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
environment.h
Go to the documentation of this file.
1
15#ifndef ENVIRONMENT_H
16#define ENVIRONMENT_H
17
18#include "lf_types.h"
19#include "low_level_platform.h"
20#include "tracepoint.h"
21
22// Forward declarations so that a pointers can appear in the environment struct.
26typedef struct watchdog_t watchdog_t;
27
40#define GLOBAL_ENVIRONMENT NULL
41
52typedef struct environment_t {
60
68
75 char* name;
76
83 int id;
84
92
97
105
110
118
126
134
141
149
156
164
172
180
187
195
202
210
217
225
232
240
247
255
263
264#if defined(LF_SINGLE_THREADED)
271 pqueue_t* reaction_q;
272#else
280
287 lf_thread_t* thread_ids;
288
295 lf_mutex_t mutex;
296
304
312
320
328#endif // LF_SINGLE_THREADED
329
330#if defined(FEDERATED)
339
347
356#endif // FEDERATED
357
358#ifdef LF_ENCLAVES
367#endif
369
370#if defined(MODAL_REACTORS)
425#endif
426
445int environment_init(environment_t* env, const char* name, int id, int num_workers, int num_timers,
446 int num_startup_reactions, int num_shutdown_reactions, int num_reset_reactions,
447 int num_is_present_fields, int num_modes, int num_state_resets, int num_watchdogs,
448 const char* trace_file_name);
449
456
463
472
481
482#endif // ENVIRONMENT_H
struct lf_scheduler_t lf_scheduler_t
Definition environment.h:23
struct enclave_info_t enclave_info_t
Definition environment.h:25
struct watchdog_t watchdog_t
Definition environment.h:26
int64_t instant_t
Time instant.
Definition tag.h:101
int64_t interval_t
Interval of time.
Definition tag.h:107
int trigger_handle_t
Handles for scheduled triggers.
Definition lf_types.h:146
int environment_init(environment_t *env, const char *name, int id, int num_workers, int num_timers, int num_startup_reactions, int num_shutdown_reactions, int num_reset_reactions, int num_is_present_fields, int num_modes, int num_state_resets, int num_watchdogs, const char *trace_file_name)
Initialize an environment struct with parameters given in the arguments.
int _lf_get_environments(environment_t **envs)
Update the argument to point to the beginning of the array of environments in this program.
pqueue_t pqueue_tag_t
Type of a priority queue sorted by tags.
Definition pqueue_tag.h:89
void environment_verify(environment_t *env)
Verify that the environment is correctly set up.
void environment_init_tags(environment_t *env, instant_t start_time, interval_t duration)
Initialize the start and stop tags on the environment struct.
void environment_free(environment_t *env)
Free the dynamically allocated memory on the environment struct.
Type definitions that are widely used across different parts of the runtime.
Platform API support for the C target of Lingua Franca.
instant_t duration
Structure holding information about each enclave in the program.
Definition rti_local.h:30
Execution environment.
Definition environment.h:52
int is_present_fields_abbreviated_size
Number of abbreviated is_present fields allocated.
Definition environment.h:155
lf_mutex_t mutex
Mutex for synchronizing access to the environment.
Definition environment.h:295
int is_present_fields_size
Number of is_present fields allocated.
Definition environment.h:140
int timer_triggers_size
Number of timer triggers allocated.
Definition environment.h:186
lf_cond_t event_q_changed
Condition variable for event queue changes.
Definition environment.h:303
int watchdogs_size
Number of watchdogs allocated.
Definition environment.h:246
int id
Unique numeric identifier for this environment.
Definition environment.h:83
bool initialized
Indicates whether the environment has been initialized.
Definition environment.h:59
int num_workers
Number of worker threads.
Definition environment.h:279
mode_environment_t * modes
Mode environment for modal reactors.
Definition environment.h:239
int reset_reactions_size
Number of reset reactions allocated.
Definition environment.h:231
lf_tag_advancement_barrier_t barrier
Barrier for tag advancement.
Definition environment.h:319
char * name
Name identifier for this environment.
Definition environment.h:75
trigger_t ** timer_triggers
Array of timer triggers.
Definition environment.h:179
int worker_thread_count
Number of worker threads in this environment.
Definition environment.h:262
reaction_t ** startup_reactions
Array of startup reactions.
Definition environment.h:194
tag_t stop_tag
The tag at which execution should stop.
Definition environment.h:104
int startup_reactions_size
Number of startup reactions allocated.
Definition environment.h:201
enclave_info_t * enclave_info
Information about the scheduling enclave.
Definition environment.h:366
reaction_t ** reset_reactions
Array of reset reactions.
Definition environment.h:224
pqueue_tag_t * recycle_q
Priority queue for recycling events.
Definition environment.h:125
bool execution_started
Indicates whether execution has started.
Definition environment.h:67
tag_t ** _lf_intended_tag_fields
Array of intended tag fields for federated execution.
Definition environment.h:338
reaction_t ** shutdown_reactions
Array of shutdown reactions.
Definition environment.h:209
int shutdown_reactions_size
Number of shutdown reactions allocated.
Definition environment.h:216
lf_cond_t global_tag_barrier_requestors_reached_zero
Condition variable for tag barrier requestors.
Definition environment.h:327
bool ** is_present_fields
Array of is_present fields for ports.
Definition environment.h:133
trigger_handle_t _lf_handle
Handle for the environment's trigger.
Definition environment.h:171
watchdog_t ** watchdogs
Array of watchdog timers.
Definition environment.h:254
interval_t duration
The duration of the environment, which is the time interval between the start tag and the stop tag.
Definition environment.h:109
int _lf_intended_tag_fields_size
Number of intended tag fields allocated.
Definition environment.h:346
tag_t current_tag
The current logical tag being processed.
Definition environment.h:91
bool ** is_present_fields_abbreviated
Abbreviated version of is_present fields.
Definition environment.h:148
vector_t sparse_io_record_sizes
Vector storing sizes of sparse I/O records.
Definition environment.h:163
lf_scheduler_t * scheduler
Scheduler for managing worker threads.
Definition environment.h:311
lf_thread_t * thread_ids
Array of worker thread IDs.
Definition environment.h:287
pqueue_tag_t * event_q
Priority queue for pending events.
Definition environment.h:117
bool need_to_send_LTC
Flag indicating if a logical tag complete (LTC) message needs to be sent.
Definition environment.h:355
tag_t start_tag
The start tag of the environment.
Definition environment.h:96
Parameters used in schedulers of the threaded reactor C runtime.
Definition scheduler_instance.h:35
A struct representing a barrier in threaded LF programs.
Definition lf_types.h:72
Environment for modal reactors.
Definition environment.h:379
uint8_t triggered_reactions_request
Bitmap indicating which reactions have been requested to trigger.
Definition environment.h:387
int state_resets_size
Number of state reset entries allocated.
Definition environment.h:423
reactor_mode_state_t ** modal_reactor_states
Array of modal reactor states.
Definition environment.h:397
int modal_reactor_states_size
Number of modal reactor states allocated.
Definition environment.h:405
mode_state_variable_reset_data_t * state_resets
Array of state variable reset data.
Definition environment.h:414
A struct to store data for resetting state variables nested in modes.
Definition modes.h:146
The priority queue struct.
Definition pqueue_base.h:103
Reaction activation record to push onto the reaction queue.
Definition lf_types.h:195
A struct to store state of the modes in a reactor instance and/or its relation to enclosing modes.
Definition modes.h:109
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
A vector (resizing array) data type.
Definition vector.h:29
Typdef for watchdog_t struct, used to call watchdog handler.
Definition watchdog.h:34
instant_t start_time
Definitions of tracepoint functions for use with the C code generator and any other code generator th...