Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: lf-lang/reactor-c
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4c860daaf10ebd7ee8991f78d8810331e39b8102
Choose a base ref
..
head repository: lf-lang/reactor-c
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 31d62b2cdf4969bd48dac25f1718a1676dce5c67
Choose a head ref
Showing with 7,191 additions and 8,340 deletions.
  1. +0 −7 .gitignore
  2. +2 −4 CMakeLists.txt
  3. +25 −89 core/CMakeLists.txt
  4. +21 −55 core/environment.c
  5. +3 −2 core/federated/CMakeLists.txt
  6. +5 −11 core/federated/RTI/CMakeLists.txt
  7. +2 −14 core/federated/RTI/README.md
  8. +308 −0 core/federated/RTI/enclave.c
  9. +263 −0 core/federated/RTI/enclave.h
  10. +20 −0 core/federated/RTI/enclave_impl.c
  11. +0 −13 core/federated/RTI/local_rti.cmake
  12. +0 −349 core/federated/RTI/main.c
  13. +173 −0 core/federated/RTI/message_record/message_record.c
  14. +84 −0 core/federated/RTI/message_record/message_record.h
  15. +98 −0 core/federated/RTI/message_record/rti_pqueue_support.h
  16. +134 −0 core/federated/RTI/rti.c
  17. +0 −395 core/federated/RTI/rti_common.c
  18. +0 −289 core/federated/RTI/rti_common.h
  19. +1,800 −0 core/federated/RTI/rti_lib.c
  20. +153 −48 core/federated/RTI/{rti_remote.h → rti_lib.h}
  21. +0 −200 core/federated/RTI/rti_local.c
  22. +0 −92 core/federated/RTI/rti_local.h
  23. +0 −1,837 core/federated/RTI/rti_remote.c
  24. +29 −11 core/federated/clock-sync.c
  25. +2,346 −2,294 core/federated/federate.c
  26. +63 −115 core/federated/{network → }/net_util.c
  27. +0 −4 core/federated/network/CMakeLists.txt
  28. +2 −1 core/modal_models/CMakeLists.txt
  29. +7 −9 core/modal_models/modes.c
  30. +19 −16 core/platform/CMakeLists.txt
  31. +1 −1 core/platform/lf_arduino_support.c
  32. +3 −9 core/reactor.c
  33. +152 −191 core/reactor_common.c
  34. +15 −18 core/tag.c
  35. +2 −1 core/threaded/CMakeLists.txt
  36. +89 −152 core/threaded/reactor_threaded.c
  37. +1 −1 core/threaded/scheduler_GEDF_NP.c
  38. +8 −10 core/threaded/scheduler_NP.c
  39. +5 −10 core/threaded/scheduler_adaptive.c
  40. +1 −1 core/threaded/scheduler_instance.c
  41. +3 −10 core/threaded/scheduler_sync_tag_advance.c
  42. +10 −18 core/trace.c
  43. +3 −2 core/utils/CMakeLists.txt
  44. +2 −1 core/utils/hashset/CMakeLists.txt
  45. +434 −26 core/utils/pqueue.c
  46. +0 −361 core/utils/pqueue_base.c
  47. +0 −169 core/utils/pqueue_tag.c
  48. +1 −1 core/utils/{lf_semaphore.c → semaphore.c}
  49. +102 −46 core/utils/util.c
  50. +5 −3 docs/README.md
  51. +1 −17 include/core/environment.h
  52. +2 −2 include/core/federated/clock-sync.h
  53. +221 −303 include/core/federated/federate.h
  54. +79 −59 include/core/federated/{network → }/net_common.h
  55. +63 −81 include/core/federated/{network → }/net_util.h
  56. +1 −2 include/core/lf_types.h
  57. +23 −47 include/core/reactor.h
  58. +17 −4 include/core/reactor_common.h
  59. +4 −20 include/core/tag.h
  60. +2 −2 include/core/threaded/reactor_threaded.h
  61. +1 −1 include/core/threaded/scheduler_instance.h
  62. +2 −21 include/core/trace.h
  63. +185 −54 include/core/utils/pqueue.h
  64. +0 −215 include/core/utils/pqueue_base.h
  65. +0 −178 include/core/utils/pqueue_tag.h
  66. 0 include/core/utils/{lf_semaphore.h → semaphore.h}
  67. +24 −55 include/core/utils/util.h
  68. +2 −1 lingua-franca-ref.txt
  69. +1 −1 python/lib/pythontarget.c
  70. +0 −104 test/general/utils/pqueue_test.c
  71. +0 −14 test/src_gen_stub.c
  72. +1 −1 util/tracing/Makefile
  73. +159 −244 util/tracing/trace_to_csv.c
  74. +0 −6 util/tracing/visualization/README.md
  75. +9 −22 util/tracing/visualization/fedsd.py
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -9,10 +9,3 @@

# Generated trace files
*.lft
util/tracing/trace_to_chrome
util/tracing/trace_to_chrome.o
util/tracing/trace_to_csv
util/tracing/trace_to_csv.o
util/tracing/trace_to_influxdb
util/tracing/trace_to_influxdb.o
util/tracing/trace_util.o
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -24,14 +24,12 @@ endif()

set(Test test)
set(Lib lib)
set(CoreLibPath core)
set(CoreLib reactor-c)
set(CoreLib core)
set(PlatformLib platform)

include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/include/core)
include_directories(${CMAKE_SOURCE_DIR}/include/core/federated)
include_directories(${CMAKE_SOURCE_DIR}/include/core/federated/network)
include_directories(${CMAKE_SOURCE_DIR}/include/core/modal_models)
include_directories(${CMAKE_SOURCE_DIR}/include/core/platform)
include_directories(${CMAKE_SOURCE_DIR}/include/core/threaded)
@@ -41,6 +39,6 @@ include_directories(${CMAKE_SOURCE_DIR}/include/api)
enable_testing()
add_subdirectory(${Test})
add_subdirectory(${Lib})
add_subdirectory(${CoreLibPath})
add_subdirectory(${CoreLib})

include(test/Tests.cmake)
114 changes: 25 additions & 89 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -9,64 +9,47 @@ if (DEFINED LF_TRACE)
list(APPEND GENERAL_SOURCES trace.c)
endif()

# Add the general sources to the list of REACTORC_SOURCES
list(APPEND REACTORC_SOURCES ${GENERAL_SOURCES})
# Store all sources used to build the reactor-c lib in INFO_SOURCES
list(APPEND INFO_SOURCES ${GENERAL_SOURCES})

# Create the core library
add_library(core ${GENERAL_SOURCES})

# Add sources for either threaded or single-threaded runtime
if (DEFINED FEDERATED)
include(federated/CMakeLists.txt)
include(federated/network/CMakeLists.txt)
endif()

# Add sources for either threaded or single-threaded runtime
if(DEFINED LF_SINGLE_THREADED)
message(STATUS "Including sources for single-threaded runtime.")
list(APPEND SINGLE_THREADED_SOURCES reactor.c)
list(APPEND REACTORC_SOURCES ${SINGLE_THREADED_SOURCES})
target_sources(core PRIVATE ${SINGLE_THREADED_SOURCES})
list(APPEND INFO_SOURCES ${SINGLE_THREADED_SOURCES})
else()
message(STATUS "Including sources for threaded runtime with \
${NUMBER_OF_WORKERS} worker(s) with scheduler=${SCHEDULER} and \
tracing=${LF_TRACE}.")
include(threaded/CMakeLists.txt)
endif()

# Add sources for the local RTI if we are using scheduling enclaves
if(DEFINED LF_ENCLAVES)
include(federated/RTI/local_rti.cmake)
endif()

# Include sources from subdirectories
include(utils/CMakeLists.txt)
include(modal_models/CMakeLists.txt)
include(platform/CMakeLists.txt)

# Print sources used for compilation
list(JOIN REACTORC_SOURCES ", " PRINTABLE_SOURCE_LIST)
list(JOIN INFO_SOURCES ", " PRINTABLE_SOURCE_LIST)
message(STATUS "Including the following sources: " ${PRINTABLE_SOURCE_LIST})

# Create the reactor-c library. If we are targeting Zephyr we have to use the
# Zephyr Cmake extension to create the library and add the sources.
if(PLATFORM_ZEPHYR)
message("--- Building Zephyr library")
zephyr_library_named(reactor-c)
zephyr_library_sources(${REACTORC_SOURCES})
zephyr_library_link_libraries(kernel)
else()
add_library(reactor-c ${REACTORC_SOURCES})
endif()

# Apply compile definitions to the reactor-c library.
target_compile_definitions(reactor-c PUBLIC ${REACTORC_COMPILE_DEFS})

target_include_directories(reactor-c PUBLIC ../include)
target_include_directories(reactor-c PUBLIC ../include/core)
target_include_directories(reactor-c PUBLIC ../include/core/federated)
target_include_directories(reactor-c PUBLIC ../include/core/federated/network)
target_include_directories(reactor-c PUBLIC ../include/core/platform)
target_include_directories(reactor-c PUBLIC ../include/core/modal_models)
target_include_directories(reactor-c PUBLIC ../include/core/threaded)
target_include_directories(reactor-c PUBLIC ../include/core/utils)
target_include_directories(reactor-c PUBLIC federated/RTI/)
target_include_directories(core PUBLIC ../include)
target_include_directories(core PUBLIC ../include/core)
target_include_directories(core PUBLIC ../include/core/federated)
target_include_directories(core PUBLIC ../include/core/platform)
target_include_directories(core PUBLIC ../include/core/modal_models)
target_include_directories(core PUBLIC ../include/core/threaded)
target_include_directories(core PUBLIC ../include/core/utils)

if (APPLE)
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
@@ -81,38 +64,38 @@ if(DEFINED FEDERATED_AUTHENTICATED)
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
endif()
find_package(OpenSSL REQUIRED)
target_link_libraries(reactor-c PUBLIC OpenSSL::SSL)
target_link_libraries(core PUBLIC OpenSSL::SSL)
endif()

if(DEFINED _LF_CLOCK_SYNC_ON)
find_library(MATH_LIBRARY m)
if(MATH_LIBRARY)
target_link_libraries(reactor-c PUBLIC ${MATH_LIBRARY})
target_link_libraries(core PUBLIC ${MATH_LIBRARY})
endif()
endif()

# Link with thread library, unless we are on the Zephyr platform.
# Link with thread library, unless if we are targeting the Zephyr RTOS
if(NOT DEFINED LF_SINGLE_THREADED OR DEFINED LF_TRACE)
if (NOT PLATFORM_ZEPHYR)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Zephyr")
find_package(Threads REQUIRED)
target_link_libraries(reactor-c PUBLIC Threads::Threads)
target_link_libraries(core PUBLIC Threads::Threads)
endif()
endif()

# Macro for translating a command-line argument into compile definition for
# reactor-c lib
# core lib
macro(define X)
if(DEFINED ${X})
message(STATUS ${X}=${${X}})
target_compile_definitions(reactor-c PUBLIC ${X}=${${X}})
target_compile_definitions(core PUBLIC ${X}=${${X}})
endif(DEFINED ${X})
endmacro()

# FIXME: May want these to be application dependent, hence passed as
# parameters to Cmake.
target_compile_definitions(reactor-c PRIVATE INITIAL_EVENT_QUEUE_SIZE=10)
target_compile_definitions(reactor-c PRIVATE INITIAL_REACT_QUEUE_SIZE=10)
target_compile_definitions(reactor-c PUBLIC PLATFORM_${CMAKE_SYSTEM_NAME})
target_compile_definitions(core PRIVATE INITIAL_EVENT_QUEUE_SIZE=10)
target_compile_definitions(core PRIVATE INITIAL_REACT_QUEUE_SIZE=10)
target_compile_definitions(core PUBLIC PLATFORM_${CMAKE_SYSTEM_NAME})

# Search and apply all possible compile definitions
message(STATUS "Applying preprocessor definitions...")
@@ -140,50 +123,3 @@ define(SCHEDULER)
define(LF_SOURCE_DIRECTORY)
define(LF_PACKAGE_DIRECTORY)
define(LF_FILE_SEPARATOR)
define(WORKERS_NEEDED_FOR_FEDERATE)
define(LF_ENCLAVES)


# ==========================================================
# Stuff I added
# ==========================================================

if(${CMAKE_SYSTEM_NAME} MATCHES "Stm32")
set(CPU_PARAMETERS
-mcpu=cortex-m4
-mthumb
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp )

set(MCU_FAMILY STM32F4xx )
set(MCU_MODEL STM32F446xx )

target_compile_definitions(core PRIVATE
${MCU_MODEL}
USE_HAL_DRIVER )

target_compile_options(core PRIVATE
${CPU_PARAMETERS}
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:CXX>:
-Wno-volatile
-Wold-style-cast
-Wuseless-cast
-Wsuggest-override>
$<$<CONFIG:Debug>:-Og -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0> )

set(CUBEMX_INCLUDE_DIRECTORIES
../STM_sdk/Core/Inc
../STM_sdk/Drivers/${MCU_FAMILY}_HAL_Driver/Inc
../STM_sdk/Drivers/${MCU_FAMILY}_HAL_Driver/Inc/Legacy
../STM_sdk/Drivers/CMSIS/Device/ST/${MCU_FAMILY}/Include
../STM_sdk/Drivers/CMSIS/Include )

target_include_directories(core PUBLIC
${CUBEMX_INCLUDE_DIRECTORIES} )
endif()
# ==========================================================
76 changes: 21 additions & 55 deletions core/environment.c
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ static void environment_init_threaded(environment_t* env, int num_workers) {
#if !defined(LF_SINGLE_THREADED)
env->num_workers = num_workers;
env->thread_ids = (lf_thread_t*)calloc(num_workers, sizeof(lf_thread_t));
LF_ASSERT(env->thread_ids, "Out of memory");
lf_assert(env->thread_ids != NULL, "Out of memory");
env->barrier.requestors = 0;
env->barrier.horizon = FOREVER_TAG;

@@ -84,19 +84,15 @@ static void environment_init_modes(environment_t* env, int num_modes, int num_st
#ifdef MODAL_REACTORS
if (num_modes > 0) {
mode_environment_t* modes = (mode_environment_t *) calloc(1, sizeof(mode_environment_t));
LF_ASSERT(modes, "Out of memory");
lf_assert(modes != NULL, "Out of memory");
modes->modal_reactor_states = (reactor_mode_state_t**) calloc(num_modes, sizeof(reactor_mode_state_t*));
LF_ASSERT(modes->modal_reactor_states, "Out of memory");
lf_assert(modes->modal_reactor_states != NULL, "Out of memory");
modes->modal_reactor_states_size = num_modes;
modes->triggered_reactions_request = 0;

modes->state_resets = (mode_state_variable_reset_data_t *) calloc(num_state_resets, sizeof(mode_state_variable_reset_data_t));
lf_assert(modes->state_resets != NULL, "Out of memory");
modes->state_resets_size = num_state_resets;
if (modes->state_resets_size > 0) {
modes->state_resets = (mode_state_variable_reset_data_t *) calloc(modes->state_resets_size, sizeof(mode_state_variable_reset_data_t));
LF_ASSERT(modes->state_resets, "Out of memory");
} else {
modes->state_resets = NULL;
}

env->modes = modes;

@@ -111,13 +107,9 @@ static void environment_init_modes(environment_t* env, int num_modes, int num_st
*/
static void environment_init_federated(environment_t* env, int num_is_present_fields) {
#ifdef FEDERATED_DECENTRALIZED
if (num_is_present_fields > 0) {
env->_lf_intended_tag_fields = (tag_t**) calloc(num_is_present_fields, sizeof(tag_t*));
LF_ASSERT(env->_lf_intended_tag_fields, "Out of memory");
env->_lf_intended_tag_fields_size = num_is_present_fields;
} else {
env->_lf_intended_tag_fields_size = NULL;
}
env->_lf_intended_tag_fields = (tag_t**) calloc(num_is_present_fields, sizeof(tag_t*));
lf_assert(env->_lf_intended_tag_fields != NULL, "Out of memory");
env->_lf_intended_tag_fields_size = num_is_present_fields;
#endif
}

@@ -163,7 +155,6 @@ static void environment_free_federated(environment_t* env) {
}

void environment_free(environment_t* env) {
free(env->name);
free(env->timer_triggers);
free(env->startup_reactions);
free(env->shutdown_reactions);
@@ -184,7 +175,6 @@ void environment_free(environment_t* env) {

int environment_init(
environment_t* env,
const char *name,
int id,
int num_workers,
int num_timers,
@@ -197,57 +187,33 @@ int environment_init(
const char * trace_file_name
) {

env->name = malloc(strlen(name) + 1); // +1 for the null terminator
LF_ASSERT(env->name, "Out of memory");
strcpy(env->name, name);

env->id = id;
env->stop_tag = FOREVER_TAG;

env->timer_triggers_size=num_timers;
if(env->timer_triggers_size > 0) {
env->timer_triggers = (trigger_t **) calloc(num_timers, sizeof(trigger_t));
LF_ASSERT(env->timer_triggers, "Out of memory");
} else {
env->timer_triggers = NULL;
}
env->timer_triggers = (trigger_t **) calloc(num_timers, sizeof(trigger_t));
lf_assert(env->timer_triggers != NULL, "Out of memory");

env->startup_reactions_size=num_startup_reactions;
if (env->startup_reactions_size > 0) {
env->startup_reactions = (reaction_t **) calloc(num_startup_reactions, sizeof(reaction_t));
LF_ASSERT(env->startup_reactions, "Out of memory");
} else {
env->startup_reactions = NULL;
}
env->startup_reactions = (reaction_t **) calloc(num_startup_reactions, sizeof(reaction_t));
lf_assert(env->startup_reactions != NULL, "Out of memory");

env->shutdown_reactions_size=num_shutdown_reactions;
if(env->shutdown_reactions_size > 0) {
env->shutdown_reactions = (reaction_t **) calloc(num_shutdown_reactions, sizeof(reaction_t));
LF_ASSERT(env->shutdown_reactions, "Out of memory");
} else {
env->shutdown_reactions = NULL;
}
env->shutdown_reactions = (reaction_t **) calloc(num_shutdown_reactions, sizeof(reaction_t));
lf_assert(env->shutdown_reactions != NULL, "Out of memory");

env->reset_reactions_size=num_reset_reactions;
if (env->reset_reactions_size > 0) {
env->reset_reactions = (reaction_t **) calloc(num_reset_reactions, sizeof(reaction_t));
LF_ASSERT(env->reset_reactions, "Out of memory");
} else {
env->reset_reactions = NULL;
}
env->reset_reactions = (reaction_t **) calloc(num_reset_reactions, sizeof(reaction_t));
lf_assert(env->reset_reactions != NULL, "Out of memory");

env->is_present_fields_size = num_is_present_fields;
env->is_present_fields_abbreviated_size = 0;

if (env->is_present_fields_size > 0) {
env->is_present_fields = (bool**)calloc(num_is_present_fields, sizeof(bool*));
LF_ASSERT(env->is_present_fields, "Out of memory");
env->is_present_fields_abbreviated = (bool**)calloc(num_is_present_fields, sizeof(bool*));
LF_ASSERT(env->is_present_fields_abbreviated, "Out of memory");
} else {
env->is_present_fields = NULL;
env->is_present_fields_abbreviated = NULL;
}
env->is_present_fields = (bool**)calloc(num_is_present_fields, sizeof(bool*));
lf_assert(env->is_present_fields != NULL, "Out of memory");

env->is_present_fields_abbreviated = (bool**)calloc(num_is_present_fields, sizeof(bool*));
lf_assert(env->is_present_fields_abbreviated != NULL, "Out of memory");

env->_lf_handle=1;

5 changes: 3 additions & 2 deletions core/federated/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(FEDERATED_SOURCES clock-sync.c federate.c)
set(FEDERATED_SOURCES clock-sync.c federate.c net_util.c)
list(APPEND INFO_SOURCES ${FEDERATED_SOURCES})

list(TRANSFORM FEDERATED_SOURCES PREPEND federated/)
list(APPEND REACTORC_SOURCES ${FEDERATED_SOURCES})
target_sources(core PRIVATE ${FEDERATED_SOURCES})
Loading