[e5ca54c9] | 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 |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[e5ca54c9] | 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 EDF |
---|
| 30 | * |
---|
| 31 | * @{ |
---|
| 32 | */ |
---|
| 33 | |
---|
[e1598a6] | 34 | RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * |
---|
| 35 | _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler ) |
---|
[3891983] | 36 | { |
---|
[2369b10] | 37 | return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler ); |
---|
[3891983] | 38 | } |
---|
| 39 | |
---|
[08d9760] | 40 | RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node( |
---|
[beab7329] | 41 | Thread_Control *the_thread |
---|
| 42 | ) |
---|
| 43 | { |
---|
[08d9760] | 44 | return (Scheduler_EDF_Node *) _Scheduler_Thread_get_node( the_thread ); |
---|
[beab7329] | 45 | } |
---|
| 46 | |
---|
[f39f667a] | 47 | RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue( |
---|
| 48 | const Scheduler_Control *scheduler, |
---|
| 49 | Thread_Control *the_thread |
---|
| 50 | ) |
---|
| 51 | { |
---|
| 52 | Scheduler_EDF_Context *context = |
---|
| 53 | _Scheduler_EDF_Get_context( scheduler ); |
---|
[08d9760] | 54 | Scheduler_EDF_Node *node = _Scheduler_EDF_Thread_get_node( the_thread ); |
---|
[f39f667a] | 55 | |
---|
| 56 | _RBTree_Insert( &context->Ready, &node->Node ); |
---|
| 57 | node->queue_state = SCHEDULER_EDF_QUEUE_STATE_YES; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract( |
---|
| 61 | const Scheduler_Control *scheduler, |
---|
| 62 | Thread_Control *the_thread |
---|
| 63 | ) |
---|
| 64 | { |
---|
| 65 | Scheduler_EDF_Context *context = |
---|
| 66 | _Scheduler_EDF_Get_context( scheduler ); |
---|
[08d9760] | 67 | Scheduler_EDF_Node *node = _Scheduler_EDF_Thread_get_node( the_thread ); |
---|
[f39f667a] | 68 | |
---|
| 69 | _RBTree_Extract( &context->Ready, &node->Node ); |
---|
| 70 | } |
---|
| 71 | |
---|
[e5ca54c9] | 72 | RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body( |
---|
[e1598a6] | 73 | const Scheduler_Control *scheduler, |
---|
| 74 | Thread_Control *the_thread, |
---|
| 75 | bool force_dispatch |
---|
[e5ca54c9] | 76 | ) |
---|
| 77 | { |
---|
[e1598a6] | 78 | Scheduler_EDF_Context *context = |
---|
| 79 | _Scheduler_EDF_Get_context( scheduler ); |
---|
| 80 | RBTree_Node *first = _RBTree_First( &context->Ready, RBT_LEFT ); |
---|
[beab7329] | 81 | Scheduler_EDF_Node *node = |
---|
| 82 | _RBTree_Container_of(first, Scheduler_EDF_Node, Node); |
---|
| 83 | Thread_Control *heir = node->thread; |
---|
[e5ca54c9] | 84 | |
---|
[24934e36] | 85 | ( void ) the_thread; |
---|
[e5ca54c9] | 86 | |
---|
| 87 | _Scheduler_Update_heir( heir, force_dispatch ); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | /**@}*/ |
---|
| 91 | |
---|
| 92 | #ifdef __cplusplus |
---|
| 93 | } |
---|
| 94 | #endif |
---|
| 95 | |
---|
| 96 | #endif |
---|
| 97 | /* end of include file */ |
---|