Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign of GEDF scheduler #433

Merged
merged 42 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2c9e48f
Very incomplete start
edwardalee May 14, 2024
26d030f
Merge branch 'main' into gedf
edwardalee May 15, 2024
6111c76
Steps towards revised GEDF
edwardalee May 20, 2024
bcdc273
Merge branch 'main' into gedf
edwardalee May 20, 2024
9ca8ddd
First pass on simpler GEDF
edwardalee May 21, 2024
2df85de
Reduce notifications
edwardalee May 21, 2024
7a001d4
Fix level error and refactor
edwardalee May 22, 2024
58a24ec
Format
edwardalee May 22, 2024
9a34786
Removed unused variable
edwardalee May 22, 2024
3784e61
Merge branch 'main' into gedf
edwardalee May 22, 2024
12aa9ca
Put inline declaration first
edwardalee May 22, 2024
60be3d1
Include federate.h conditionally
edwardalee May 22, 2024
94e377c
Removed unused function
edwardalee May 22, 2024
ccf9385
Use cutsom_data field for executing_reactions
edwardalee May 22, 2024
3abd387
Moved array_of_mutexes to custom_data
edwardalee May 22, 2024
ba7fcbe
Moved triggered_reactions to custom_data
edwardalee May 22, 2024
7a6541a
Moved semaphore to custom_data
edwardalee May 22, 2024
00e4c98
Merge branch 'main' into gedf
edwardalee May 23, 2024
90ea06c
Format
edwardalee May 23, 2024
297c68b
Point to gedf master branch for testing
edwardalee May 23, 2024
d5b1a6d
File header comments only
edwardalee May 24, 2024
08f65ff
Debug statements only
edwardalee May 24, 2024
6fba73d
Comments and debug statements only
edwardalee May 24, 2024
78d8755
Comments and ifdef guard
edwardalee May 24, 2024
f363abe
Comments only
edwardalee May 24, 2024
f730dd2
Debug statement only
edwardalee May 24, 2024
5a7ca7b
File header comments only
edwardalee May 24, 2024
9ee3092
File header comments only
edwardalee May 24, 2024
167093a
Remove chain_id
edwardalee May 24, 2024
8a61851
Comments only
edwardalee May 24, 2024
db099bb
Comments only
edwardalee May 24, 2024
5c516f3
Comments only
edwardalee May 24, 2024
83502ad
Comments only
edwardalee May 24, 2024
98e97f7
Comments only
edwardalee May 24, 2024
29f657c
Comments and cleanup only
edwardalee May 24, 2024
80b16c6
Moved next_reaction_level to custom_data and out of scheduler API
edwardalee May 24, 2024
5b7aa45
Conditionally include federate.h
edwardalee May 24, 2024
afc59aa
Merge branch 'main' into gedf
edwardalee May 24, 2024
53fb8b0
Merge branch 'main' into gedf
edwardalee May 28, 2024
9f65472
Response to review
edwardalee May 28, 2024
2692433
Comment only
edwardalee May 28, 2024
d577ea9
Format
edwardalee May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions core/environment.c
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
/**
* @file
* @author Erling R. Jellum ([email protected])
* @author Erling R. Jellum
* @copyright (c) 2023-2024, The Norwegian University of Science and Technology.
* License: <a href="https://github.com/lf-lang/reactor-c/blob/main/LICENSE.md">BSD 2-clause</a>
*
* @section 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.
*
* @section DESCRIPTION Functions intitializing and freeing memory for environments.
* See environment.h for docs.
* This file defines functions intitializing and freeing memory for environments.
* See environment.h for docs.
*/

#include "environment.h"
Expand Down
14 changes: 9 additions & 5 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2611,14 +2611,18 @@ void lf_set_federation_id(const char* fid) { federation_metadata.federation_id =
void lf_spawn_staa_thread() { lf_thread_create(&_fed.staaSetter, update_ports_from_staa_offsets, NULL); }
#endif // FEDERATED_DECENTRALIZED

void lf_stall_advance_level_federation(environment_t* env, size_t level) {
LF_PRINT_DEBUG("Acquiring the environment mutex.");
LF_MUTEX_LOCK(&env->mutex);
LF_PRINT_DEBUG("Waiting on MLAA with next_reaction_level %zu and MLAA %d.", level, max_level_allowed_to_advance);
void lf_stall_advance_level_federation_locked(size_t level) {
LF_PRINT_DEBUG("Waiting for MLAA %d to exceed level %zu.", max_level_allowed_to_advance, level);
while (((int)level) >= max_level_allowed_to_advance) {
lf_cond_wait(&lf_port_status_changed);
};
LF_PRINT_DEBUG("Exiting wait with MLAA %d and next_reaction_level %zu.", max_level_allowed_to_advance, level);
LF_PRINT_DEBUG("Exiting wait with MLAA %d and level %zu.", max_level_allowed_to_advance, level);
}

void lf_stall_advance_level_federation(environment_t* env, size_t level) {
LF_PRINT_DEBUG("Acquiring the environment mutex.");
LF_MUTEX_LOCK(&env->mutex);
lf_stall_advance_level_federation_locked(level);
LF_MUTEX_UNLOCK(&env->mutex);
}

Expand Down
6 changes: 0 additions & 6 deletions core/reactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,6 @@ void lf_request_stop(void) {
lf_set_stop_tag(env, new_stop_tag);
}

/**
* Return false.
* @param reaction The reaction.
*/
bool _lf_is_blocked_by_executing_reaction(void) { return false; }

/**
* The main loop of the LF program.
*
Expand Down
29 changes: 11 additions & 18 deletions core/threaded/reactor_threaded.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @file
* @author Edward A. Lee ([email protected])
* @author{Marten Lohstroh <[email protected]>}
* @author{Soroush Bateni <[email protected]>}
* @author Edward A. Lee
* @author Marten Lohstroh
* @author Soroush Bateni
* @copyright (c) 2020-2024, The University of California at Berkeley.
* License: <a href="https://github.com/lf-lang/reactor-c/blob/main/LICENSE.md">BSD 2-clause</a>
* @brief Runtime infrastructure for the threaded version of the C target of Lingua Franca.
Expand Down Expand Up @@ -850,19 +850,13 @@ void _lf_worker_invoke_reaction(environment_t* env, int worker_number, reaction_
reaction->is_STP_violated = false;
}

void try_advance_level(environment_t* env, volatile size_t* next_reaction_level) {
#ifdef FEDERATED
lf_stall_advance_level_federation(env, *next_reaction_level);
#else
(void)env;
#endif
if (*next_reaction_level < SIZE_MAX)
*next_reaction_level += 1;
}

/**
* The main looping logic of each LF worker thread.
* This function assumes the caller holds the mutex lock.
* @brief The main looping logic of each LF worker thread.
*
* This function returns when the scheduler's lf_sched_get_ready_reaction()
* implementation returns NULL, indicating that there are no more reactions to execute.
*
* This function assumes the caller does not hold the mutex lock on the environment.
*
* @param env Environment within which we are executing.
* @param worker_number The number assigned to this worker thread
Expand All @@ -882,10 +876,9 @@ void _lf_worker_do_work(environment_t* env, int worker_number) {
while ((current_reaction_to_execute = lf_sched_get_ready_reaction(env->scheduler, worker_number)) != NULL) {
// Got a reaction that is ready to run.
LF_PRINT_DEBUG("Worker %d: Got from scheduler reaction %s: "
"level: %lld, is input reaction: %d, chain ID: %llu, and deadline " PRINTF_TIME ".",
"level: %lld, is input reaction: %d, and deadline " PRINTF_TIME ".",
worker_number, current_reaction_to_execute->name, LF_LEVEL(current_reaction_to_execute->index),
current_reaction_to_execute->is_an_input_reaction, current_reaction_to_execute->chain_id,
current_reaction_to_execute->deadline);
current_reaction_to_execute->is_an_input_reaction, current_reaction_to_execute->deadline);

bool violation = _lf_worker_handle_violations(env, worker_number, current_reaction_to_execute);

Expand Down
Loading
Loading