reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
environment.h File Reference
#include "lf_types.h"
#include "low_level_platform.h"
#include "tracepoint.h"

Go to the source code of this file.

Data Structures

struct  environment_t
 Execution environment. This struct contains information about the execution environment. An execution environment maintains a notion of a "current tag" and has its own event queue and scheduler. Normally, there is only one execution environment, but if you use scheduling enclaves, then there will be one for each enclave. More...
 

Macros

#define GLOBAL_ENVIRONMENT   NULL
 The global environment. Some operations are not specific to a particular scheduling enclave and therefore have no associated environment. When invoking a function such as lf_critical_section_enter, which requires an environment argument, it may be possible to pass this GLOBAL_ENVIRONMENT. For lf_critical_section_enter, for example, this may acquire a global mutex instead of a mutex specific to a particular scheduling enclave. Most functions that take environment arguments, however, cannot accept the GLOBAL_ENVIRONMENT argument, and passing it will result in an assertion violation.
 

Typedefs

typedef struct lf_scheduler_t lf_scheduler_t
 
typedef struct mode_environment_t mode_environment_t
 
typedef struct enclave_info_t enclave_info_t
 
typedef struct watchdog_t watchdog_t
 
typedef struct environment_t environment_t
 Execution environment. This struct contains information about the execution environment. An execution environment maintains a notion of a "current tag" and has its own event queue and scheduler. Normally, there is only one execution environment, but if you use scheduling enclaves, then there will be one for each enclave.
 

Functions

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.
 
void environment_free (environment_t *env)
 Free the dynamically allocated memory on the environment struct.
 
void environment_init_tags (environment_t *env, instant_t start_time, interval_t duration)
 Initialize the start and stop tags on the environment struct.
 
int _lf_get_environments (environment_t **envs)
 Will update the argument to point to the beginning of the array of environments in this program.
 

Detailed Description

Author
Erling R. Jellum (erlin.nosp@m.g.r..nosp@m.jellu.nosp@m.m@nt.nosp@m.nu.no)

LICENSE

Copyright (c) 2023, The Norwegian University of Science and Technology.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Functions intitializing and freeing memory for environments.

"context" within which the reactors are executed. The environment contains data structures which are shared among the reactors such as priority queues, the current logical tag, the worker scheduler, and a lot of meta data. Each reactor stores a pointer to its environment on its self-struct. If a LF program has multiple scheduling enclaves, then each enclave will have its own environment.

Macro Definition Documentation

◆ GLOBAL_ENVIRONMENT

#define GLOBAL_ENVIRONMENT   NULL

The global environment. Some operations are not specific to a particular scheduling enclave and therefore have no associated environment. When invoking a function such as lf_critical_section_enter, which requires an environment argument, it may be possible to pass this GLOBAL_ENVIRONMENT. For lf_critical_section_enter, for example, this may acquire a global mutex instead of a mutex specific to a particular scheduling enclave. Most functions that take environment arguments, however, cannot accept the GLOBAL_ENVIRONMENT argument, and passing it will result in an assertion violation.

Typedef Documentation

◆ enclave_info_t

◆ environment_t

typedef struct environment_t environment_t

Execution environment. This struct contains information about the execution environment. An execution environment maintains a notion of a "current tag" and has its own event queue and scheduler. Normally, there is only one execution environment, but if you use scheduling enclaves, then there will be one for each enclave.

◆ lf_scheduler_t

typedef struct lf_scheduler_t lf_scheduler_t

◆ mode_environment_t

◆ watchdog_t

typedef struct watchdog_t watchdog_t

Function Documentation

◆ _lf_get_environments()

int _lf_get_environments ( environment_t ** envs)

Will update the argument to point to the beginning of the array of environments in this program.

Note
Is code-generated by the compiler
Parameters
envsA double pointer which will be dereferenced and modified
Returns
int The number of environments in the array

◆ environment_free()

void environment_free ( environment_t * env)

Free the dynamically allocated memory on the environment struct.

Parameters
envThe environment in which we are executing.

◆ environment_init()

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.

◆ environment_init_tags()

void environment_init_tags ( environment_t * env,
instant_t start_time,
interval_t duration )

Initialize the start and stop tags on the environment struct.