4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Compares Priorities of Threads |
---|
5 | * |
---|
6 | * @ingroup ScoreScheduler |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (C) 2011 Petr Benes. |
---|
11 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/system.h> |
---|
23 | #include <rtems/config.h> |
---|
24 | #include <rtems/score/scheduleredf.h> |
---|
25 | |
---|
26 | int _Scheduler_EDF_Priority_compare ( |
---|
27 | Priority_Control p1, |
---|
28 | Priority_Control p2 |
---|
29 | ) |
---|
30 | { |
---|
31 | Watchdog_Interval time = _Watchdog_Ticks_since_boot; |
---|
32 | |
---|
33 | /* |
---|
34 | * Reorder priorities to separate deadline driven and background tasks. |
---|
35 | * |
---|
36 | * The background tasks have p1 or p2 > SCHEDULER_EDF_PRIO_MSB. |
---|
37 | * The deadline driven tasks need to have subtracted current time in order |
---|
38 | * to see which deadline is closer wrt. current time. |
---|
39 | */ |
---|
40 | if (!(p1 & SCHEDULER_EDF_PRIO_MSB)) |
---|
41 | p1 = (p1 - time) & ~SCHEDULER_EDF_PRIO_MSB; |
---|
42 | if (!(p2 & SCHEDULER_EDF_PRIO_MSB)) |
---|
43 | p2 = (p2 - time) & ~SCHEDULER_EDF_PRIO_MSB; |
---|
44 | |
---|
45 | return ((p1<p2) - (p1>p2)); |
---|
46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.