summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/scheduleredf.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src/scheduleredf.c')
-rw-r--r--cpukit/score/src/scheduleredf.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/cpukit/score/src/scheduleredf.c b/cpukit/score/src/scheduleredf.c
index 00b6181e59..372612819a 100644
--- a/cpukit/score/src/scheduleredf.c
+++ b/cpukit/score/src/scheduleredf.c
@@ -20,6 +20,28 @@
#include <rtems/score/scheduleredfimpl.h>
+int _Scheduler_EDF_Priority_compare (
+ Priority_Control p1,
+ Priority_Control p2
+)
+{
+ Watchdog_Interval time = _Watchdog_Ticks_since_boot;
+
+ /*
+ * Reorder priorities to separate deadline driven and background tasks.
+ *
+ * The background tasks have p1 or p2 > SCHEDULER_EDF_PRIO_MSB.
+ * The deadline driven tasks need to have subtracted current time in order
+ * to see which deadline is closer wrt. current time.
+ */
+ if (!(p1 & SCHEDULER_EDF_PRIO_MSB))
+ p1 = (p1 - time) & ~SCHEDULER_EDF_PRIO_MSB;
+ if (!(p2 & SCHEDULER_EDF_PRIO_MSB))
+ p2 = (p2 - time) & ~SCHEDULER_EDF_PRIO_MSB;
+
+ return ((p1<p2) - (p1>p2));
+}
+
RBTree_Compare_result _Scheduler_EDF_Compare(
const RBTree_Node* n1,
const RBTree_Node* n2