[m-rev.] for review: disable concurrency in non .par LLDS grades
Julien Fischer
jfischer at opturion.com
Thu Aug 21 13:05:54 AEST 2025
For review by Peter.
-----------------------------------------------
Disable concurrency in non .par LLDS grades.
The non .par LLDS grades currently "support" concurrency. However, this support
is really on usable with a small few benchmark programs, due to the inability
of the implementation to switch threads if the executing thread blocks. Disable
this capability by causing spawn/3 to abort if used in non .par LLDS grades.
library/thread.m:
Make the above change to spawn/3.
compiler/globals.m:
Update the code that checks if the current grade supports concurrency.
Julien.
diff --git a/compiler/globals.m b/compiler/globals.m
index 576a3d9ff..ec1d61edf 100644
--- a/compiler/globals.m
+++ b/compiler/globals.m
@@ -1226,16 +1226,8 @@ current_grade_supports_concurrency(Globals,
ThreadsSupported) :-
globals.get_target(Globals, Target),
(
Target = target_c,
- globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode),
- % In high-level C grades we only support threads in .par grades.
- (
- HighLevelCode = no,
- ThreadsSupported = yes
- ;
- HighLevelCode = yes,
- globals.lookup_bool_option(Globals, parallel, Parallel),
- ThreadsSupported = Parallel
- )
+ globals.lookup_bool_option(Globals, parallel, Parallel),
+ ThreadsSupported = Parallel
;
( Target = target_java
; Target = target_csharp
diff --git a/library/thread.m b/library/thread.m
index 029742edd..0417a8368 100644
--- a/library/thread.m
+++ b/library/thread.m
@@ -251,7 +251,7 @@ can_spawn :-
can_spawn_context,
[will_not_call_mercury, promise_pure, thread_safe, may_not_duplicate],
"
-#if !defined(MR_HIGHLEVEL_CODE)
+#if !defined(MR_HIGHLEVEL_CODE) && defined(MR_THREAD_SAFE)
SUCCESS_INDICATOR = MR_TRUE;
#else
SUCCESS_INDICATOR = MR_FALSE;
More information about the reviews
mailing list