1 | /** |
---|
2 | * @file rtems/posix/pthread.h |
---|
3 | */ |
---|
4 | |
---|
5 | /* rtems/posix/pthread.h |
---|
6 | * |
---|
7 | * This include file contains all the private support information for |
---|
8 | * POSIX threads. |
---|
9 | * |
---|
10 | * COPYRIGHT (c) 1989-2008. |
---|
11 | * 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.com/license/LICENSE. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef _RTEMS_POSIX_PTHREAD_H |
---|
21 | #define _RTEMS_POSIX_PTHREAD_H |
---|
22 | |
---|
23 | |
---|
24 | #include <rtems/posix/config.h> |
---|
25 | #include <rtems/posix/threadsup.h> |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif |
---|
30 | /** |
---|
31 | * The following sets the minimum stack size for POSIX threads. |
---|
32 | */ |
---|
33 | #define PTHREAD_MINIMUM_STACK_SIZE (_Stack_Minimum() * 2) |
---|
34 | |
---|
35 | /** |
---|
36 | * The following defines the information control block used to manage |
---|
37 | * this class of objects. |
---|
38 | */ |
---|
39 | POSIX_EXTERN Objects_Information _POSIX_Threads_Information; |
---|
40 | |
---|
41 | /** |
---|
42 | * This variable contains the default POSIX Thread attributes. |
---|
43 | */ |
---|
44 | extern const pthread_attr_t _POSIX_Threads_Default_attributes; |
---|
45 | |
---|
46 | /** |
---|
47 | * When the user configures a set of POSIX API initialization threads, |
---|
48 | * This variable will point to the method used to initialize them. |
---|
49 | * |
---|
50 | * @note It is instantiated and initialized by confdefs.h based upon |
---|
51 | * application requirements. |
---|
52 | */ |
---|
53 | extern void (*_POSIX_Threads_Initialize_user_threads_p)(void); |
---|
54 | |
---|
55 | /** |
---|
56 | * @brief _POSIX_Threads_Manager_initialization |
---|
57 | * |
---|
58 | * This routine performs the initialization necessary for this manager. |
---|
59 | */ |
---|
60 | void _POSIX_Threads_Manager_initialization(void); |
---|
61 | |
---|
62 | /** |
---|
63 | * @brief _POSIX_Threads_Allocate |
---|
64 | * |
---|
65 | * This function allocates a pthread control block from |
---|
66 | * the inactive chain of free pthread control blocks. |
---|
67 | * |
---|
68 | * @return This method returns a newly allocated thread. |
---|
69 | */ |
---|
70 | RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate( void ); |
---|
71 | |
---|
72 | /** |
---|
73 | * @brief _POSIX_Threads_Free |
---|
74 | * |
---|
75 | * This routine frees a pthread control block to the |
---|
76 | * inactive chain of free pthread control blocks. |
---|
77 | * |
---|
78 | * @param[in] the_pthread is the thread to free |
---|
79 | */ |
---|
80 | RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free( |
---|
81 | Thread_Control *the_pthread |
---|
82 | ); |
---|
83 | |
---|
84 | /** |
---|
85 | * @brief _POSIX_Threads_Get |
---|
86 | * |
---|
87 | * This function maps pthread IDs to pthread control blocks. |
---|
88 | * If ID corresponds to a local pthread, then it returns |
---|
89 | * the_pthread control pointer which maps to ID and location |
---|
90 | * is set to OBJECTS_LOCAL. if the pthread ID is global and |
---|
91 | * resides on a remote node, then location is set to OBJECTS_REMOTE, |
---|
92 | * and the_pthread is undefined. Otherwise, location is set |
---|
93 | * to OBJECTS_ERROR and the_pthread is undefined. |
---|
94 | * |
---|
95 | * @param[in] id is the id to lookup |
---|
96 | * @param[in] location points to the returned location value |
---|
97 | * |
---|
98 | * @return This methods returns a pointer to the corresponding Thread_Control. |
---|
99 | */ |
---|
100 | RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Get( |
---|
101 | pthread_t id, |
---|
102 | Objects_Locations *location |
---|
103 | ); |
---|
104 | |
---|
105 | /** |
---|
106 | * @brief _POSIX_Threads_Is_null |
---|
107 | * |
---|
108 | * This function returns TRUE if the_pthread is NULL and FALSE otherwise. |
---|
109 | * |
---|
110 | * @param[in] the_pthread is the thread pointer to check. |
---|
111 | * |
---|
112 | * @return This method returns true if the thread pointer is null. |
---|
113 | */ |
---|
114 | RTEMS_INLINE_ROUTINE bool _POSIX_Threads_Is_null( |
---|
115 | Thread_Control *the_pthread |
---|
116 | ); |
---|
117 | |
---|
118 | /** |
---|
119 | * @brief _POSIX_Threads_Sporadic_budget_callout |
---|
120 | * |
---|
121 | * This routine handles the sporadic scheduling algorithm. |
---|
122 | * |
---|
123 | * @param[in] the_thread is the thread whose budget has been exceeded. |
---|
124 | */ |
---|
125 | void _POSIX_Threads_Sporadic_budget_callout( |
---|
126 | Thread_Control *the_thread |
---|
127 | ); |
---|
128 | |
---|
129 | /** |
---|
130 | * _POSIX_Threads_Sporadic_budget_TSR |
---|
131 | * |
---|
132 | * This routine supports the sporadic scheduling algorithm. |
---|
133 | * |
---|
134 | * @param[in] the_thread is the thread whose budget has been exceeded. |
---|
135 | */ |
---|
136 | void _POSIX_Threads_Sporadic_budget_TSR( |
---|
137 | Objects_Id id, |
---|
138 | void *argument |
---|
139 | ); |
---|
140 | |
---|
141 | /** |
---|
142 | * @brief Translate sched_param into SuperCore Terms |
---|
143 | * |
---|
144 | * This method translates the POSIX API sched_param into the corresponding |
---|
145 | * SuperCore settings. |
---|
146 | * |
---|
147 | * @param[in] policy is the POSIX scheduling policy |
---|
148 | * @param[in] param points to the scheduling parameter structure |
---|
149 | * @param[in] budget_algorithm points to the output CPU Budget algorithm |
---|
150 | * @param[in] budget_callout points to the output CPU Callout |
---|
151 | * |
---|
152 | * @return This method returns 0 on success or a POSIX error code. |
---|
153 | */ |
---|
154 | int _POSIX_Thread_Translate_sched_param( |
---|
155 | int policy, |
---|
156 | struct sched_param *param, |
---|
157 | Thread_CPU_budget_algorithms *budget_algorithm, |
---|
158 | Thread_CPU_budget_algorithm_callout *budget_callout |
---|
159 | ); |
---|
160 | |
---|
161 | #include <rtems/posix/pthread.inl> |
---|
162 | |
---|
163 | #ifdef __cplusplus |
---|
164 | } |
---|
165 | #endif |
---|
166 | |
---|
167 | #endif |
---|
168 | /* end of include file */ |
---|