1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Inlined Routines Associated with the Manipulation of the |
---|
5 | * Priority-Based Scheduling Structures |
---|
6 | * |
---|
7 | * This inline file contains all of the inlined routines associated with |
---|
8 | * the manipulation of the priority-based scheduling structures. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H |
---|
20 | #define _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H |
---|
21 | |
---|
22 | #include <rtems/score/schedulersimple.h> |
---|
23 | #include <rtems/score/chainimpl.h> |
---|
24 | #include <rtems/score/schedulerimpl.h> |
---|
25 | |
---|
26 | #ifdef __cplusplus |
---|
27 | extern "C" { |
---|
28 | #endif |
---|
29 | |
---|
30 | /** |
---|
31 | * @addtogroup ScoreSchedulerSimple |
---|
32 | */ |
---|
33 | /**@{**/ |
---|
34 | |
---|
35 | RTEMS_INLINE_ROUTINE Scheduler_simple_Context * |
---|
36 | _Scheduler_simple_Get_context( const Scheduler_Control *scheduler ) |
---|
37 | { |
---|
38 | return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler ); |
---|
39 | } |
---|
40 | |
---|
41 | RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order( |
---|
42 | const Chain_Node *to_insert, |
---|
43 | const Chain_Node *next |
---|
44 | ) |
---|
45 | { |
---|
46 | const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert; |
---|
47 | const Thread_Control *thread_next = (const Thread_Control *) next; |
---|
48 | |
---|
49 | return thread_to_insert->current_priority <= thread_next->current_priority; |
---|
50 | } |
---|
51 | |
---|
52 | RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order( |
---|
53 | const Chain_Node *to_insert, |
---|
54 | const Chain_Node *next |
---|
55 | ) |
---|
56 | { |
---|
57 | const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert; |
---|
58 | const Thread_Control *thread_next = (const Thread_Control *) next; |
---|
59 | |
---|
60 | return thread_to_insert->current_priority < thread_next->current_priority; |
---|
61 | } |
---|
62 | |
---|
63 | RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_lifo( |
---|
64 | Chain_Control *chain, |
---|
65 | Thread_Control *to_insert |
---|
66 | ) |
---|
67 | { |
---|
68 | _Chain_Insert_ordered_unprotected( |
---|
69 | chain, |
---|
70 | &to_insert->Object.Node, |
---|
71 | _Scheduler_simple_Insert_priority_lifo_order |
---|
72 | ); |
---|
73 | } |
---|
74 | |
---|
75 | RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_fifo( |
---|
76 | Chain_Control *chain, |
---|
77 | Thread_Control *to_insert |
---|
78 | ) |
---|
79 | { |
---|
80 | _Chain_Insert_ordered_unprotected( |
---|
81 | chain, |
---|
82 | &to_insert->Object.Node, |
---|
83 | _Scheduler_simple_Insert_priority_fifo_order |
---|
84 | ); |
---|
85 | } |
---|
86 | |
---|
87 | RTEMS_INLINE_ROUTINE void _Scheduler_simple_Extract( |
---|
88 | const Scheduler_Control *scheduler, |
---|
89 | Thread_Control *the_thread |
---|
90 | ) |
---|
91 | { |
---|
92 | (void) scheduler; |
---|
93 | |
---|
94 | _Chain_Extract_unprotected( &the_thread->Object.Node ); |
---|
95 | } |
---|
96 | |
---|
97 | RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body( |
---|
98 | const Scheduler_Control *scheduler, |
---|
99 | Thread_Control *the_thread, |
---|
100 | bool force_dispatch |
---|
101 | ) |
---|
102 | { |
---|
103 | Scheduler_simple_Context *context = |
---|
104 | _Scheduler_simple_Get_context( scheduler ); |
---|
105 | Thread_Control *heir = (Thread_Control *) _Chain_First( &context->Ready ); |
---|
106 | |
---|
107 | ( void ) the_thread; |
---|
108 | |
---|
109 | _Scheduler_Update_heir( heir, force_dispatch ); |
---|
110 | } |
---|
111 | |
---|
112 | /** @} */ |
---|
113 | |
---|
114 | #ifdef __cplusplus |
---|
115 | } |
---|
116 | #endif |
---|
117 | |
---|
118 | #endif |
---|
119 | /* end of include file */ |
---|