Skip to content

Commit

Permalink
Merge pull request #2442 from lf-lang/default-np
Browse files Browse the repository at this point in the history
Use the NP scheduler when deadlines are present
  • Loading branch information
lsk567 authored Nov 30, 2024
2 parents 2f1c28e + fbcd226 commit 800679b
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions core/src/main/java/org/lflang/generator/c/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
import org.lflang.target.property.TracingProperty;
import org.lflang.target.property.WorkersProperty;
import org.lflang.target.property.type.PlatformType.Platform;
import org.lflang.target.property.type.SchedulerType.Scheduler;
import org.lflang.util.ArduinoUtil;
import org.lflang.util.FileUtil;
import org.lflang.util.FlexPRETUtil;
Expand Down Expand Up @@ -741,31 +740,6 @@ else if (term.getParameter() != null)
return result.toString();
}

/** Set the scheduler type in the target config as needed. */
private void pickScheduler() {
// Don't use a scheduler that does not prioritize reactions based on deadlines
// if the program contains a deadline (handler). Use the GEDF_NP scheduler instead.
if (!targetConfig.get(SchedulerProperty.INSTANCE).prioritizesDeadline()) {
// Check if a deadline is assigned to any reaction
if (hasDeadlines(reactors)) {
if (!targetConfig.isSet(SchedulerProperty.INSTANCE)) {
SchedulerProperty.INSTANCE.override(targetConfig, Scheduler.GEDF_NP);
}
}
}
}

private boolean hasDeadlines(List<Reactor> reactors) {
for (Reactor reactor : reactors) {
for (Reaction reaction : allReactions(reactor)) {
if (reaction.getDeadline() != null) {
return true;
}
}
}
return false;
}

/**
* Copy all files or directories listed in the target property {@code files}, {@code
* cmake-include}, and {@code _fed_setup} into the src-gen folder of the main .lf file
Expand Down Expand Up @@ -2033,7 +2007,6 @@ protected boolean setUpGeneralParameters() {
CompileDefinitionsProperty.INSTANCE.update(targetConfig, Map.of("MODAL_REACTORS", "TRUE"));
}
if (!targetConfig.get(SingleThreadedProperty.INSTANCE)) {
pickScheduler();
CompileDefinitionsProperty.INSTANCE.update(
targetConfig,
Map.of(
Expand Down

0 comments on commit 800679b

Please sign in to comment.