reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
lf_types.h File Reference

Type definitions that are widely used across different parts of the runtime. More...

#include <stdbool.h>
#include "modal_models/modes.h"
#include "utils/pqueue.h"
#include "utils/pqueue_tag.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
 The base type for all reactor self structs. More...
 
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
 

Typedefs

typedef unsigned short int ushort
 
typedef struct _lf_tag_advancement_barrier _lf_tag_advancement_barrier
 
typedef int trigger_handle_t
 
typedef char * string
 
typedef pqueue_pri_t index_t
 
typedef void(* reaction_function_t) (void *)
 
typedef struct trigger_t trigger_t
 
typedef struct reaction_t reaction_t
 
typedef struct event_t event_t
 
typedef struct allocation_record_t allocation_record_t
 
typedef struct environment_t environment_t
 
typedef struct self_base_t self_base_t
 The base type for all reactor self structs.
 

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 }
 

Detailed Description

Type definitions that are widely used across different parts of the runtime.

Author
Edward A. Lee (eal@b.nosp@m.erke.nosp@m.ley.e.nosp@m.du)
Marten Lohstroh (marte.nosp@m.n@be.nosp@m.rkele.nosp@m.y.ed.nosp@m.u)
Chris Gill (cdgil.nosp@m.l@wu.nosp@m.stl.e.nosp@m.du)
Mehrdad Niknami (mnikn.nosp@m.ami@.nosp@m.berke.nosp@m.ley..nosp@m.edu)

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.

Macro Definition Documentation

◆ SCHED_ADAPTIVE

#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.

◆ SCHED_GEDF_NP

#define SCHED_GEDF_NP   2

◆ SCHED_NP

#define SCHED_NP   3

Typedef Documentation

◆ _lf_tag_advancement_barrier

typedef struct _lf_tag_advancement_barrier _lf_tag_advancement_barrier

◆ allocation_record_t

typedef struct allocation_record_t allocation_record_t

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.

◆ environment_t

typedef struct environment_t environment_t

◆ event_t

typedef struct event_t event_t

Typedef for event_t struct, used for storing activation records.

◆ index_t

Topological order index for reactions.

◆ reaction_function_t

typedef void(* reaction_function_t) (void *)

Reaction function type. The argument passed to one of these reaction functions is a pointer to the self struct for the reactor.

◆ reaction_t

typedef struct reaction_t reaction_t

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.

◆ self_base_t

typedef struct self_base_t self_base_t

The base type for all reactor self structs.

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. This list is used to free memory that has been dynamically allocated. This struct also provides a pointer to the currently executing reaction, to the environment in which the reaction is executing, and to the mutex that is used to protect the reactor. If modal models are being used, it also records the current mode.

◆ string

typedef char* string

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*.

◆ trigger_handle_t

typedef int trigger_handle_t

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_t

typedef struct trigger_t trigger_t

Trigger struct representing an output, timer, action, or input. See below.

◆ ushort

typedef unsigned short int ushort

ushort type. Redefine here for portability if sys/types.h is not included.

See also
sys/types.h
Note
using sizeof(ushort) should be okay but not sizeof ushort.

Enumeration Type Documentation

◆ lf_spacing_policy_t

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 

◆ port_status_t

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).

Note
For non-network ports, unknown is unused.
The absent and present fields need to be compatible with false and true respectively because for non-network ports, the status can either be present or absent (no possibility of unknown).
Enumerator
absent 
present 
unknown 

◆ reaction_status_t

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.

Note
inactive must equal zero because it should be possible to allocate a reaction with default values using calloc. FIXME: The running state does not seem to be read.
Enumerator
inactive 
queued 
running