reactor-c
C Runtime for Lingua Franca
|
#include <stdbool.h>
#include "modal_models/modes.h"
#include "utils/pqueue.h"
#include "lf_token.h"
#include "tag.h"
#include "vector.h"
Go to the source code of this file.
Data Structures | |
struct | _lf_tag_advancement_barrier |
struct | reaction_t |
struct | event_t |
struct | trigger_t |
struct | allocation_record_t |
struct | self_base_t |
struct | lf_action_base_t |
struct | lf_action_internal_t |
struct | lf_port_internal_t |
Internal part of the port structs. HAS TO MATCH lf_port_base_t after tmplt and is_present. More... | |
Macros | |
#define | SCHED_ADAPTIVE 1 |
#define | SCHED_GEDF_NP 2 |
#define | SCHED_NP 3 |
Enumerations | |
enum | lf_spacing_policy_t { defer , drop , replace } |
enum | port_status_t { absent = false , present = true , unknown } |
enum | reaction_status_t { inactive = 0 , queued , running } |
Copyright (c) 2019, The University of California at Berkeley.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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.
Type definitions that are widely used across different parts of the runtime.
IMPORTANT: Many of the structs defined here require matching layouts and, if changed, will require changes in the code generator. See Structs in the Reactor-C Runtime.
#define SCHED_ADAPTIVE 1 |
Define scheduler types as integers. This way we can conditionally include/exclude code with the preprocessor with if SCHEDULER == SCHED_ADAPTIVE etc This means that lf_types.h
MUST be included before doing any preprocessing on SCHEDULER compile def.
#define SCHED_GEDF_NP 2 |
#define SCHED_NP 3 |
An allocation record that is used by a destructor for a reactor to free memory that has been dynamically allocated for the particular instance of the reactor. This will be an element of linked list. If the indirect field is true, then the allocated pointer points to pointer to allocated memory, rather than directly to the allocated memory.
Topological order index for reactions.
Reaction function type. The argument passed to one of these reaction functions is a pointer to the self struct for the reactor.
Reaction activation record to push onto the reaction queue. Some of the information in this struct is common among all instances of the reactor, and some is specific to each particular instance. These are marked below COMMON or INSTANCE accordingly. The COMMON information is set in the constructor. The fields marked RUNTIME have values that change during execution. Instances of this struct are put onto the reaction queue by the scheduler.
The first element of every self struct defined in generated code will be a pointer to an allocation record, which is either NULL or the head of a NULL-terminated linked list of allocation records. Casting the self struct to this type enables access to this list by the function _lf_free_reactor(self_base_t*)
. To allocate memory for the reactor that will be freed by that function, allocate the memory using _lf_allocate(size_t,size_t,self_base_t*)
.
String type so that we don't have to use {= char* =}. Use this for strings that are not dynamically allocated. For dynamically allocated strings that have to be freed after being consumed downstream, use type char*.
Handles for scheduled triggers. These handles are returned by lf_schedule() functions. The intent is that the handle can be used to cancel a future scheduled event, but this is not implemented yet.
Trigger struct representing an output, timer, action, or input. See below.
ushort type. Redefine here for portability if sys/types.h is not included.
Policy for handling scheduled events that violate the specified minimum interarrival time. The default policy is defer
: adjust the tag to that the minimum interarrival time is satisfied. The drop
policy simply drops events that are scheduled too early. The replace
policy will attempt to replace the value of the event that it preceded it. Unless the preceding event has already been handled, its gets assigned the value of the new event. If the preceding event has already been popped off the event queue, the defer
policy is fallen back to.
Enumerator | |
---|---|
defer | |
drop | |
replace |
Status of a given port at a given logical time.
If the value is 'present', it is an indicator that the port is present at the given logical time. If the value is 'absent', it is an indicator that the port is absent at the given logical time. If the value is 'unknown', it is unknown whether the port is present or absent (e.g., in a distributed application).
Enumerator | |
---|---|
absent | |
present | |
unknown |
Status of a given reaction at a given logical time.
If a reaction is 'inactive', it is neither running nor queued. If a reaction is 'queued', it is going to be executed at the current logical time, but it has not started running yet. If a reaction is 'running', its body is being executed.
Enumerator | |
---|---|
inactive | |
queued | |
running |