source: rtems/cpukit/score/src/scheduleredfprioritycompare.c @ 2369b10

4.115
Last change on this file since 2369b10 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.2 KB
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.org/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#include <rtems/score/watchdogimpl.h>
26
27int _Scheduler_EDF_Priority_compare (
28  Priority_Control p1,
29  Priority_Control p2
30)
31{
32  Watchdog_Interval time = _Watchdog_Ticks_since_boot;
33
34  /*
35   * Reorder priorities to separate deadline driven and background tasks.
36   *
37   * The background tasks have p1 or p2 > SCHEDULER_EDF_PRIO_MSB.
38   * The deadline driven tasks need to have subtracted current time in order
39   * to see which deadline is closer wrt. current time.
40   */
41  if (!(p1 & SCHEDULER_EDF_PRIO_MSB))
42    p1 = (p1 - time) & ~SCHEDULER_EDF_PRIO_MSB;
43  if (!(p2 & SCHEDULER_EDF_PRIO_MSB))
44    p2 = (p2 - time) & ~SCHEDULER_EDF_PRIO_MSB;
45
46  return ((p1<p2) - (p1>p2));
47}
Note: See TracBrowser for help on using the repository browser.