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;
28
41
54#define GLOBAL_ENVIRONMENT NULL
55
66typedef struct environment_t {
74
82
89 char* name;
90
97 int id;
98
106
111
119
124
132
140
148
155
163
170
178
186
194
201
209
216
224
231
239
246
254
261
269
277
278#if defined(LF_SINGLE_THREADED)
285 pqueue_t* reaction_q;
286#else
295
303
311 lf_thread_t* thread_ids;
312
319 lf_mutex_t mutex;
320
328
336
344
352
362
370
377
384
394#endif // LF_SINGLE_THREADED
395
396#if defined(FEDERATED)
405
413
422#endif // FEDERATED
423
424#ifdef LF_ENCLAVES
433#endif
435
436#if defined(MODAL_REACTORS)
491#endif
492
511int environment_init(environment_t* env, const char* name, int id, int num_workers, int num_timers,
512 int num_startup_reactions, int num_shutdown_reactions, int num_reset_reactions,
513 int num_is_present_fields, int num_modes, int num_state_resets, int num_watchdogs,
514 const char* trace_file_name);
515
522
529
538
547
548#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 lf_async_state_t lf_async_state_t
Definition environment.h:27
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:66
int is_present_fields_abbreviated_size
Number of abbreviated is_present fields allocated.
Definition environment.h:169
lf_async_physical_owner_t * async_physical_owners
Physical actions passed to lf_async(), and the reaction each is dedicated to.
Definition environment.h:376
lf_mutex_t mutex
Mutex for synchronizing access to the environment.
Definition environment.h:319
int num_async_threads
Number of worker threads that have been added by lf_async().
Definition environment.h:383
int is_present_fields_size
Number of is_present fields allocated.
Definition environment.h:154
int timer_triggers_size
Number of timer triggers allocated.
Definition environment.h:200
lf_cond_t event_q_changed
Condition variable for event queue changes.
Definition environment.h:327
int watchdogs_size
Number of watchdogs allocated.
Definition environment.h:260
lf_async_state_t * async_deferred
Calls whose resuming reaction has run, waiting for the scheduler to reach their level.
Definition environment.h:369
int id
Unique numeric identifier for this environment.
Definition environment.h:97
bool initialized
Indicates whether the environment has been initialized.
Definition environment.h:73
int num_workers
Number of worker threads.
Definition environment.h:294
mode_environment_t * modes
Mode environment for modal reactors.
Definition environment.h:253
int reset_reactions_size
Number of reset reactions allocated.
Definition environment.h:245
lf_tag_advancement_barrier_t barrier
Barrier for tag advancement.
Definition environment.h:343
char * name
Name identifier for this environment.
Definition environment.h:89
trigger_t ** timer_triggers
Array of timer triggers.
Definition environment.h:193
int num_added_workers
Number of worker threads added at runtime.
Definition environment.h:302
int worker_thread_count
Number of worker threads in this environment.
Definition environment.h:276
reaction_t ** startup_reactions
Array of startup reactions.
Definition environment.h:208
tag_t stop_tag
The tag at which execution should stop.
Definition environment.h:118
int startup_reactions_size
Number of startup reactions allocated.
Definition environment.h:215
enclave_info_t * enclave_info
Information about the scheduling enclave.
Definition environment.h:432
reaction_t ** reset_reactions
Array of reset reactions.
Definition environment.h:238
pqueue_tag_t * recycle_q
Priority queue for recycling events.
Definition environment.h:139
bool execution_started
Indicates whether execution has started.
Definition environment.h:81
tag_t ** _lf_intended_tag_fields
Array of intended tag fields for federated execution.
Definition environment.h:404
reaction_t ** shutdown_reactions
Array of shutdown reactions.
Definition environment.h:223
int shutdown_reactions_size
Number of shutdown reactions allocated.
Definition environment.h:230
lf_cond_t global_tag_barrier_requestors_reached_zero
Condition variable for tag barrier requestors.
Definition environment.h:351
bool ** is_present_fields
Array of is_present fields for ports.
Definition environment.h:147
trigger_handle_t _lf_handle
Handle for the environment's trigger.
Definition environment.h:185
watchdog_t ** watchdogs
Array of watchdog timers.
Definition environment.h:268
lf_async_state_t * async_waiters
Pending lf_async() and lf_await() calls in this environment, oldest first.
Definition environment.h:361
interval_t duration
The duration of the environment, which is the time interval between the start tag and the stop tag.
Definition environment.h:123
int _lf_intended_tag_fields_size
Number of intended tag fields allocated.
Definition environment.h:412
tag_t current_tag
The current logical tag being processed.
Definition environment.h:105
bool ** is_present_fields_abbreviated
Abbreviated version of is_present fields.
Definition environment.h:162
vector_t sparse_io_record_sizes
Vector storing sizes of sparse I/O records.
Definition environment.h:177
lf_scheduler_t * scheduler
Scheduler for managing worker threads.
Definition environment.h:335
lf_thread_t * thread_ids
Array of worker thread IDs.
Definition environment.h:311
pqueue_tag_t * event_q
Priority queue for pending events.
Definition environment.h:131
int num_async_suspended
Number of reactions currently suspended in lf_async().
Definition environment.h:393
bool need_to_send_LTC
Flag indicating if a logical tag complete (LTC) message needs to be sent.
Definition environment.h:421
tag_t start_tag
The start tag of the environment.
Definition environment.h:110
Base type for actions.
Definition lf_types.h:583
A physical action dedicated to one reaction by lf_async().
Definition environment.h:36
lf_action_base_t * action
Definition environment.h:37
reaction_t * reaction
Definition environment.h:38
struct lf_async_physical_owner_t * next
Definition environment.h:39
State of a pending lf_async() call.
Definition reactor.h:203
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:445
uint8_t triggered_reactions_request
Bitmap indicating which reactions have been requested to trigger.
Definition environment.h:453
int state_resets_size
Number of state reset entries allocated.
Definition environment.h:489
reactor_mode_state_t ** modal_reactor_states
Array of modal reactor states.
Definition environment.h:463
int modal_reactor_states_size
Number of modal reactor states allocated.
Definition environment.h:471
mode_state_variable_reset_data_t * state_resets
Array of state variable reset data.
Definition environment.h:480
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...