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/assert.h> |
---|
26 | #include <rtems/score/objectimpl.h> |
---|
27 | #include <rtems/score/timespec.h> |
---|
28 | #include <rtems/score/threadimpl.h> |
---|
29 | #include <rtems/score/watchdogimpl.h> |
---|
30 | |
---|
31 | #ifdef __cplusplus |
---|
32 | extern "C" { |
---|
33 | #endif |
---|
34 | |
---|
35 | /** |
---|
36 | * @addtogroup POSIX_PTHREAD |
---|
37 | */ |
---|
38 | /**@{**/ |
---|
39 | |
---|
40 | /** |
---|
41 | * The following sets the minimum stack size for POSIX threads. |
---|
42 | */ |
---|
43 | #define PTHREAD_MINIMUM_STACK_SIZE _POSIX_Threads_Minimum_stack_size |
---|
44 | |
---|
45 | #if defined(RTEMS_POSIX_API) |
---|
46 | RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert( |
---|
47 | Thread_Control *the_thread, |
---|
48 | POSIX_API_Control *api |
---|
49 | ) |
---|
50 | { |
---|
51 | the_thread->cpu_time_budget = |
---|
52 | _Timespec_To_ticks( &api->Sporadic.sched_ss_init_budget ); |
---|
53 | |
---|
54 | _Watchdog_Per_CPU_insert_ticks( |
---|
55 | &api->Sporadic.Timer, |
---|
56 | _Per_CPU_Get(), |
---|
57 | _Timespec_To_ticks( &api->Sporadic.sched_ss_repl_period ) |
---|
58 | ); |
---|
59 | } |
---|
60 | #endif |
---|
61 | |
---|
62 | void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog ); |
---|
63 | |
---|
64 | /** |
---|
65 | * @brief POSIX threads sporadic budget callout. |
---|
66 | * |
---|
67 | * This routine handles the sporadic scheduling algorithm. |
---|
68 | * |
---|
69 | * @param[in] the_thread is a pointer to the thread whose budget |
---|
70 | * has been exceeded. |
---|
71 | */ |
---|
72 | void _POSIX_Threads_Sporadic_budget_callout( |
---|
73 | Thread_Control *the_thread |
---|
74 | ); |
---|
75 | |
---|
76 | int _POSIX_Thread_Translate_to_sched_policy( |
---|
77 | Thread_CPU_budget_algorithms budget_algorithm |
---|
78 | ); |
---|
79 | |
---|
80 | /** |
---|
81 | * @brief Translate sched_param into SuperCore terms. |
---|
82 | * |
---|
83 | * This method translates the POSIX API sched_param into the corresponding |
---|
84 | * SuperCore settings. |
---|
85 | * |
---|
86 | * @param[in] policy is the POSIX scheduling policy |
---|
87 | * @param[in] param points to the scheduling parameter structure |
---|
88 | * @param[in] budget_algorithm points to the output CPU Budget algorithm |
---|
89 | * @param[in] budget_callout points to the output CPU Callout |
---|
90 | * |
---|
91 | * @retval 0 Indicates success. |
---|
92 | * @retval error_code POSIX error code indicating failure. |
---|
93 | */ |
---|
94 | int _POSIX_Thread_Translate_sched_param( |
---|
95 | int policy, |
---|
96 | const struct sched_param *param, |
---|
97 | Thread_CPU_budget_algorithms *budget_algorithm, |
---|
98 | Thread_CPU_budget_algorithm_callout *budget_callout |
---|
99 | ); |
---|
100 | |
---|
101 | RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void) |
---|
102 | { |
---|
103 | _Objects_Allocator_lock(); |
---|
104 | |
---|
105 | _Thread_Kill_zombies(); |
---|
106 | |
---|
107 | return (Thread_Control *) |
---|
108 | _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects ); |
---|
109 | } |
---|
110 | |
---|
111 | RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free ( |
---|
112 | Thread_Control *the_pthread |
---|
113 | ) |
---|
114 | { |
---|
115 | _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object ); |
---|
116 | } |
---|
117 | |
---|
118 | /** @} */ |
---|
119 | |
---|
120 | #ifdef __cplusplus |
---|
121 | } |
---|
122 | #endif |
---|
123 | |
---|
124 | #endif |
---|
125 | /* end of include file */ |
---|