1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Scheduler EDF Initialize and Support |
---|
5 | * @ingroup ScoreScheduler |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Copyright (C) 2011 Petr Benes. |
---|
10 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/scheduleredf.h> |
---|
22 | #include <rtems/score/schedulerimpl.h> |
---|
23 | #include <rtems/score/thread.h> |
---|
24 | |
---|
25 | static int _Scheduler_EDF_RBTree_compare_function |
---|
26 | ( |
---|
27 | const RBTree_Node* n1, |
---|
28 | const RBTree_Node* n2 |
---|
29 | ) |
---|
30 | { |
---|
31 | Priority_Control value1 = _RBTree_Container_of |
---|
32 | (n1,Scheduler_EDF_Per_thread,Node)->thread->current_priority; |
---|
33 | Priority_Control value2 = _RBTree_Container_of |
---|
34 | (n2,Scheduler_EDF_Per_thread,Node)->thread->current_priority; |
---|
35 | |
---|
36 | /* |
---|
37 | * This function compares only numbers for the red-black tree, |
---|
38 | * but priorities have an opposite sense. |
---|
39 | */ |
---|
40 | return (-1)*_Scheduler_Priority_compare(value1, value2); |
---|
41 | } |
---|
42 | |
---|
43 | void _Scheduler_EDF_Initialize(void) |
---|
44 | { |
---|
45 | _RBTree_Initialize_empty( |
---|
46 | &_Scheduler_EDF_Ready_queue, |
---|
47 | &_Scheduler_EDF_RBTree_compare_function, |
---|
48 | 0 |
---|
49 | ); |
---|
50 | } |
---|
51 | |
---|
52 | /* Instantiate any global variables needed by the EDF scheduler */ |
---|
53 | RBTree_Control _Scheduler_EDF_Ready_queue; |
---|