From c052d653d0737076c7aafdc2b5e87d6814ff5f07 Mon Sep 17 00:00:00 2001 From: Samuel Berkun Date: Sun, 6 Oct 2024 22:19:24 -0700 Subject: [PATCH 1/4] disable interrupts for global mutex --- core/threaded/reactor_threaded.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/threaded/reactor_threaded.c b/core/threaded/reactor_threaded.c index 82dd2b648..27d1960bc 100644 --- a/core/threaded/reactor_threaded.c +++ b/core/threaded/reactor_threaded.c @@ -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); @@ -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; + } + return lf_enable_interrupts_nested(); } else { return lf_mutex_unlock(&env->mutex); } From 3acce7a40b1ffddf40fcb711602a6a377c75908d Mon Sep 17 00:00:00 2001 From: erlingrj Date: Sun, 27 Oct 2024 18:48:21 -0700 Subject: [PATCH 2/4] Format --- core/threaded/reactor_threaded.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/threaded/reactor_threaded.c b/core/threaded/reactor_threaded.c index 27d1960bc..424dd4ec2 100644 --- a/core/threaded/reactor_threaded.c +++ b/core/threaded/reactor_threaded.c @@ -1153,7 +1153,7 @@ 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 + // 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) { From 6c2ffb6c2627585bfa5c823772178fe21dd8d372 Mon Sep 17 00:00:00 2001 From: erling Date: Sun, 27 Oct 2024 18:49:53 -0700 Subject: [PATCH 3/4] Update core/threaded/reactor_threaded.c Co-authored-by: Edward A. Lee --- core/threaded/reactor_threaded.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/threaded/reactor_threaded.c b/core/threaded/reactor_threaded.c index 424dd4ec2..bb8ac3d57 100644 --- a/core/threaded/reactor_threaded.c +++ b/core/threaded/reactor_threaded.c @@ -1173,6 +1173,7 @@ int lf_critical_section_exit(environment_t* env) { if (env == GLOBAL_ENVIRONMENT) { int ret_code = lf_mutex_unlock(&global_mutex); if (ret_code != 0) { + lf_enable_interrupts_nested(); return ret_code; } return lf_enable_interrupts_nested(); From c822e4dc15821ad9119b7bce8880024041ae6f5d Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Thu, 7 Nov 2024 14:19:27 -0800 Subject: [PATCH 4/4] Update lingua-franca-ref.txt to point to master --- lingua-franca-ref.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lingua-franca-ref.txt b/lingua-franca-ref.txt index edf165c42..1f7391f92 100644 --- a/lingua-franca-ref.txt +++ b/lingua-franca-ref.txt @@ -1 +1 @@ -fix-concurrency \ No newline at end of file +master