source: rtems/cpukit/posix/include/rtems/posix/pthreadimpl.h @ 03b900d

5
Last change on this file since 03b900d was 03b900d, checked in by Sebastian Huber <sebastian.huber@…>, on 02/18/16 at 07:36:26

score: Replace watchdog handler implementation

Use a red-black tree instead of delta chains.

Close #2344.
Update #2554.
Update #2555.
Close #2606.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief POSIX Threads Private Support
5 *
6 * This include file contains all the private support information for
7 * POSIX threads.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2011.
12 *  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_POSIX_PTHREADIMPL_H
20#define _RTEMS_POSIX_PTHREADIMPL_H
21
22#include <rtems/posix/pthread.h>
23#include <rtems/posix/config.h>
24#include <rtems/posix/threadsup.h>
25#include <rtems/score/objectimpl.h>
26#include <rtems/score/threadimpl.h>
27#include <rtems/score/assert.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 * @addtogroup POSIX_PTHREAD
35 */
36/**@{**/
37
38/**
39 * The following sets the minimum stack size for POSIX threads.
40 */
41#define PTHREAD_MINIMUM_STACK_SIZE (_Stack_Minimum() * 2)
42
43/**
44 * The following defines the information control block used to manage
45 * this class of objects.
46 */
47extern Thread_Information _POSIX_Threads_Information;
48
49/**
50 * This variable contains the default POSIX Thread attributes.
51 */
52extern pthread_attr_t _POSIX_Threads_Default_attributes;
53
54/**
55 * @brief Copy POSIX Thread attribute structure.
56 *
57 * This routine copies the attr2 thread attribute structure
58 * to the attr1 Thread Attribute structure.
59 *
60 * @param[in] dst_attr is a pointer to the thread attribute
61 * structure to copy into.
62 *
63 * @param[out] src_attr is a pointer to the thread attribute
64 * structure to copy from.
65 */
66RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes(
67  pthread_attr_t        *dst_attr,
68  const pthread_attr_t  *src_attr
69);
70
71/**
72 * @brief Free POSIX control block.
73 *
74 * This routine frees a pthread control block to the
75 * inactive chain of free pthread control blocks.
76 *
77 * @param[in] the_pthread is a pointer to the thread to free.
78 */
79RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free(
80  Thread_Control *the_pthread
81);
82
83/**
84 * @brief POSIX threads initialize user threads body.
85 *
86 * This routine initializes the thread attributes structure.
87 */
88RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
89  pthread_attr_t  *attr
90);
91
92/**
93 * @brief POSIX threads sporadic budget callout.
94 *
95 * This routine handles the sporadic scheduling algorithm.
96 *
97 * @param[in] the_thread is a pointer to the thread whose budget
98 * has been exceeded.
99 */
100void _POSIX_Threads_Sporadic_budget_callout(
101  Thread_Control *the_thread
102);
103
104/**
105 * This routine supports the sporadic scheduling algorithm.  It
106 * is scheduled to be executed at the end of each replenishment
107 * period.  In sporadic scheduling a thread will execute at a
108 * high priority for a user specified amount of CPU time.  When
109 * it exceeds that amount of CPU time, its priority is automatically
110 * lowered. This TSR is executed when it is time to replenish
111 * the thread's processor budget and raise its priority.
112 *
113 * @param[in] id is ignored
114 * @param[in] argument is a pointer to the Thread_Control structure
115 *            for the thread being replenished.
116 */
117void _POSIX_Threads_Sporadic_budget_TSR( Watchdog_Control *watchdog );
118
119/**
120 * @brief Translate sched_param into SuperCore terms.
121 *
122 * This method translates the POSIX API sched_param into the corresponding
123 * SuperCore settings.
124 *
125 * @param[in] policy is the POSIX scheduling policy
126 * @param[in] param points to the scheduling parameter structure
127 * @param[in] budget_algorithm points to the output CPU Budget algorithm
128 * @param[in] budget_callout points to the output CPU Callout
129 *
130 * @retval 0 Indicates success.
131 * @retval error_code POSIX error code indicating failure.
132 */
133int _POSIX_Thread_Translate_sched_param(
134  int                                  policy,
135  struct sched_param                  *param,
136  Thread_CPU_budget_algorithms        *budget_algorithm,
137  Thread_CPU_budget_algorithm_callout *budget_callout
138);
139
140/*
141 * rtems_pthread_attribute_compare
142 */
143int rtems_pthread_attribute_compare(
144  const pthread_attr_t *attr1,
145  const pthread_attr_t *attr2
146);
147
148RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void)
149{
150  _Objects_Allocator_lock();
151
152  _Thread_Kill_zombies();
153
154  return (Thread_Control *)
155    _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects );
156}
157
158/*
159 * _POSIX_Threads_Copy_attributes
160 */
161
162RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes(
163  pthread_attr_t        *dst_attr,
164  const pthread_attr_t  *src_attr
165)
166{
167  *dst_attr = *src_attr;
168#if defined(RTEMS_SMP) && defined(__RTEMS_HAVE_SYS_CPUSET_H__)
169  _Assert(
170    dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated)
171  );
172  dst_attr->affinityset = &dst_attr->affinitysetpreallocated;
173#endif
174}
175
176/*
177 *  _POSIX_Threads_Free
178 */
179
180RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free (
181  Thread_Control *the_pthread
182)
183{
184  _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object );
185}
186
187/*
188 * _POSIX_Threads_Initialize_attributes
189 */
190
191RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
192  pthread_attr_t  *attr
193)
194{
195  _POSIX_Threads_Copy_attributes(
196    attr,
197    &_POSIX_Threads_Default_attributes
198  );
199}
200
201/*
202 *  _POSIX_Threads_Is_null
203 */
204
205RTEMS_INLINE_ROUTINE bool _POSIX_Threads_Is_null (
206  Thread_Control *the_pthread
207)
208{
209  return !the_pthread;
210}
211
212/** @} */
213
214#ifdef __cplusplus
215}
216#endif
217
218#endif
219/*  end of include file */
Note: See TracBrowser for help on using the repository browser.