1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ClassicTasksImpl |
---|
5 | * |
---|
6 | * @brief Classic Tasks Manager Implementation |
---|
7 | */ |
---|
8 | |
---|
9 | /* COPYRIGHT (c) 1989-2014. |
---|
10 | * 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.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _RTEMS_RTEMS_TASKSIMPL_H |
---|
18 | #define _RTEMS_RTEMS_TASKSIMPL_H |
---|
19 | |
---|
20 | #include <rtems/rtems/tasks.h> |
---|
21 | #include <rtems/score/objectimpl.h> |
---|
22 | #include <rtems/score/threadimpl.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** |
---|
29 | * @defgroup ClassicTasksImpl Classic Tasks Manager Implementation |
---|
30 | * |
---|
31 | * @ingroup ClassicTasks |
---|
32 | * |
---|
33 | * @{ |
---|
34 | */ |
---|
35 | |
---|
36 | /** |
---|
37 | * The following instantiates the information control block used to |
---|
38 | * manage this class of objects. |
---|
39 | */ |
---|
40 | extern Thread_Information _RTEMS_tasks_Information; |
---|
41 | |
---|
42 | /** |
---|
43 | * @brief RTEMS User Task Initialization |
---|
44 | * |
---|
45 | * This routine creates and starts all configured user |
---|
46 | * initialization threads. |
---|
47 | */ |
---|
48 | void _RTEMS_tasks_Initialize_user_tasks( void ); |
---|
49 | |
---|
50 | #if !defined(RTEMS_SMP) |
---|
51 | /** |
---|
52 | * @brief RTEMS Tasks Invoke Task Variable Destructor |
---|
53 | * |
---|
54 | * @deprecated Task variables are deprecated. |
---|
55 | * |
---|
56 | * This routine invokes the optional user provided destructor on the |
---|
57 | * task variable and frees the memory for the task variable. |
---|
58 | */ |
---|
59 | void _RTEMS_Tasks_Invoke_task_variable_dtor( |
---|
60 | Thread_Control *the_thread, |
---|
61 | rtems_task_variable_t *tvp |
---|
62 | ) RTEMS_DEPRECATED; |
---|
63 | #endif |
---|
64 | |
---|
65 | RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void) |
---|
66 | { |
---|
67 | _Objects_Allocator_lock(); |
---|
68 | |
---|
69 | _Thread_Kill_zombies(); |
---|
70 | |
---|
71 | return (Thread_Control *) |
---|
72 | _Objects_Allocate_unprotected( &_RTEMS_tasks_Information.Objects ); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * @brief Frees a task control block. |
---|
77 | * |
---|
78 | * This routine frees a task control block to the |
---|
79 | * inactive chain of free task control blocks. |
---|
80 | */ |
---|
81 | RTEMS_INLINE_ROUTINE void _RTEMS_tasks_Free ( |
---|
82 | Thread_Control *the_task |
---|
83 | ) |
---|
84 | { |
---|
85 | _Objects_Free( |
---|
86 | _Objects_Get_information_id( the_task->Object.id ), |
---|
87 | &the_task->Object |
---|
88 | ); |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * @brief Converts an RTEMS API priority into a core priority. |
---|
93 | * |
---|
94 | * This function converts an RTEMS API priority into a core priority. |
---|
95 | */ |
---|
96 | RTEMS_INLINE_ROUTINE Priority_Control _RTEMS_tasks_Priority_to_Core( |
---|
97 | rtems_task_priority priority |
---|
98 | ) |
---|
99 | { |
---|
100 | return (Priority_Control) priority; |
---|
101 | } |
---|
102 | |
---|
103 | /** |
---|
104 | * @brief Converts a core priority into an RTEMS API priority. |
---|
105 | * |
---|
106 | * This function converts a core priority into an RTEMS API priority. |
---|
107 | */ |
---|
108 | RTEMS_INLINE_ROUTINE rtems_task_priority _RTEMS_tasks_Priority_from_Core ( |
---|
109 | Priority_Control priority |
---|
110 | ) |
---|
111 | { |
---|
112 | return (rtems_task_priority) priority; |
---|
113 | } |
---|
114 | |
---|
115 | /** |
---|
116 | * @brief Checks whether the priority is a valid user task. |
---|
117 | * |
---|
118 | * This function returns TRUE if the_priority is a valid user task priority |
---|
119 | * and FALSE otherwise. |
---|
120 | */ |
---|
121 | RTEMS_INLINE_ROUTINE bool _RTEMS_tasks_Priority_is_valid ( |
---|
122 | rtems_task_priority the_priority |
---|
123 | ) |
---|
124 | { |
---|
125 | return ( ( the_priority >= RTEMS_MINIMUM_PRIORITY ) && |
---|
126 | ( the_priority <= RTEMS_MAXIMUM_PRIORITY ) ); |
---|
127 | } |
---|
128 | |
---|
129 | /**@}*/ |
---|
130 | |
---|
131 | #if defined(RTEMS_MULTIPROCESSING) |
---|
132 | #include <rtems/rtems/taskmp.h> |
---|
133 | #endif |
---|
134 | |
---|
135 | #ifdef __cplusplus |
---|
136 | } |
---|
137 | #endif |
---|
138 | |
---|
139 | #endif |
---|
140 | /* end of include file */ |
---|