1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreSchedulerEDF |
---|
5 | * |
---|
6 | * @brief EDF Scheduler Implementation |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copryight (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 | #ifndef _RTEMS_SCORE_SCHEDULEREDFIMPL_H |
---|
19 | #define _RTEMS_SCORE_SCHEDULEREDFIMPL_H |
---|
20 | |
---|
21 | #include <rtems/score/scheduleredf.h> |
---|
22 | #include <rtems/score/schedulerimpl.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** |
---|
29 | * @addtogroup ScoreSchedulerEDF |
---|
30 | * |
---|
31 | * @{ |
---|
32 | */ |
---|
33 | |
---|
34 | RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * |
---|
35 | _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler ) |
---|
36 | { |
---|
37 | return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler ); |
---|
38 | } |
---|
39 | |
---|
40 | RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node( |
---|
41 | Thread_Control *the_thread |
---|
42 | ) |
---|
43 | { |
---|
44 | return (Scheduler_EDF_Node *) _Scheduler_Thread_get_node( the_thread ); |
---|
45 | } |
---|
46 | |
---|
47 | int _Scheduler_EDF_Priority_compare ( |
---|
48 | Priority_Control p1, |
---|
49 | Priority_Control p2 |
---|
50 | ); |
---|
51 | |
---|
52 | RBTree_Compare_result _Scheduler_EDF_Compare( |
---|
53 | const RBTree_Node* n1, |
---|
54 | const RBTree_Node* n2 |
---|
55 | ); |
---|
56 | |
---|
57 | RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue( |
---|
58 | const Scheduler_Control *scheduler, |
---|
59 | Thread_Control *the_thread |
---|
60 | ) |
---|
61 | { |
---|
62 | Scheduler_EDF_Context *context = |
---|
63 | _Scheduler_EDF_Get_context( scheduler ); |
---|
64 | Scheduler_EDF_Node *node = _Scheduler_EDF_Thread_get_node( the_thread ); |
---|
65 | |
---|
66 | _RBTree_Insert( |
---|
67 | &context->Ready, |
---|
68 | &node->Node, |
---|
69 | _Scheduler_EDF_Compare, |
---|
70 | false |
---|
71 | ); |
---|
72 | node->queue_state = SCHEDULER_EDF_QUEUE_STATE_YES; |
---|
73 | } |
---|
74 | |
---|
75 | RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract( |
---|
76 | const Scheduler_Control *scheduler, |
---|
77 | Thread_Control *the_thread |
---|
78 | ) |
---|
79 | { |
---|
80 | Scheduler_EDF_Context *context = |
---|
81 | _Scheduler_EDF_Get_context( scheduler ); |
---|
82 | Scheduler_EDF_Node *node = _Scheduler_EDF_Thread_get_node( the_thread ); |
---|
83 | |
---|
84 | _RBTree_Extract( &context->Ready, &node->Node ); |
---|
85 | } |
---|
86 | |
---|
87 | RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body( |
---|
88 | const Scheduler_Control *scheduler, |
---|
89 | Thread_Control *the_thread, |
---|
90 | bool force_dispatch |
---|
91 | ) |
---|
92 | { |
---|
93 | Scheduler_EDF_Context *context = |
---|
94 | _Scheduler_EDF_Get_context( scheduler ); |
---|
95 | RBTree_Node *first = _RBTree_Minimum( &context->Ready ); |
---|
96 | Scheduler_EDF_Node *node = |
---|
97 | RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node ); |
---|
98 | Thread_Control *heir = node->thread; |
---|
99 | |
---|
100 | ( void ) the_thread; |
---|
101 | |
---|
102 | _Scheduler_Update_heir( heir, force_dispatch ); |
---|
103 | } |
---|
104 | |
---|
105 | /**@}*/ |
---|
106 | |
---|
107 | #ifdef __cplusplus |
---|
108 | } |
---|
109 | #endif |
---|
110 | |
---|
111 | #endif |
---|
112 | /* end of include file */ |
---|