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

disable interrupts for global mutex #488

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
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
13 changes: 12 additions & 1 deletion core/threaded/reactor_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,13 @@ int lf_notify_of_event(environment_t* env) {
*/
int lf_critical_section_enter(environment_t* env) {
if (env == GLOBAL_ENVIRONMENT) {
// disabling interrupts prevents possible deadlock
// when reaction is scheduled from an interrupt
// on a core that holds the global mutex
int ret_code = lf_disable_interrupts_nested();
if (ret_code != 0) {
return ret_code;
}
return lf_mutex_lock(&global_mutex);
} else {
return lf_mutex_lock(&env->mutex);
Expand All @@ -1164,7 +1171,11 @@ int lf_critical_section_enter(environment_t* env) {
*/
int lf_critical_section_exit(environment_t* env) {
if (env == GLOBAL_ENVIRONMENT) {
return lf_mutex_unlock(&global_mutex);
int ret_code = lf_mutex_unlock(&global_mutex);
if (ret_code != 0) {
return ret_code;
erlingrj marked this conversation as resolved.
Show resolved Hide resolved
}
return lf_enable_interrupts_nested();
} else {
return lf_mutex_unlock(&env->mutex);
}
Expand Down
Loading