1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * This include file contains the static inline implementation of the private |
---|
5 | * inlined routines for POSIX condition variables. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2013. |
---|
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_POSIX_CONDIMPL_H |
---|
18 | #define _RTEMS_POSIX_CONDIMPL_H |
---|
19 | |
---|
20 | #include <rtems/posix/cond.h> |
---|
21 | #include <rtems/score/objectimpl.h> |
---|
22 | #include <rtems/score/threadqimpl.h> |
---|
23 | |
---|
24 | #include <errno.h> |
---|
25 | |
---|
26 | #ifdef __cplusplus |
---|
27 | extern "C" { |
---|
28 | #endif |
---|
29 | |
---|
30 | /** |
---|
31 | * Constant to indicate condition variable does not currently have |
---|
32 | * a mutex assigned to it. |
---|
33 | */ |
---|
34 | #define POSIX_CONDITION_VARIABLES_NO_MUTEX NULL |
---|
35 | |
---|
36 | #define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO |
---|
37 | |
---|
38 | #define POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue ) \ |
---|
39 | RTEMS_CONTAINER_OF( \ |
---|
40 | queue, POSIX_Condition_variables_Control, Wait_queue.Queue ) |
---|
41 | |
---|
42 | /** |
---|
43 | * The following defines the information control block used to manage |
---|
44 | * this class of objects. |
---|
45 | */ |
---|
46 | extern Objects_Information _POSIX_Condition_variables_Information; |
---|
47 | |
---|
48 | /** |
---|
49 | * The default condition variable attributes structure. |
---|
50 | */ |
---|
51 | extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes; |
---|
52 | |
---|
53 | RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize( |
---|
54 | POSIX_Condition_variables_Control *the_cond, |
---|
55 | const pthread_condattr_t *the_attr |
---|
56 | ) |
---|
57 | { |
---|
58 | _Thread_queue_Object_initialize( &the_cond->Wait_queue ); |
---|
59 | the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX; |
---|
60 | the_cond->clock = the_attr->clock; |
---|
61 | } |
---|
62 | |
---|
63 | RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Destroy( |
---|
64 | POSIX_Condition_variables_Control *the_cond |
---|
65 | ) |
---|
66 | { |
---|
67 | _Thread_queue_Destroy( &the_cond->Wait_queue ); |
---|
68 | } |
---|
69 | |
---|
70 | RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Acquire_critical( |
---|
71 | POSIX_Condition_variables_Control *the_cond, |
---|
72 | Thread_queue_Context *queue_context |
---|
73 | ) |
---|
74 | { |
---|
75 | _Thread_queue_Acquire_critical( &the_cond->Wait_queue, queue_context ); |
---|
76 | } |
---|
77 | |
---|
78 | RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release( |
---|
79 | POSIX_Condition_variables_Control *the_cond, |
---|
80 | Thread_queue_Context *queue_context |
---|
81 | ) |
---|
82 | { |
---|
83 | _Thread_queue_Release( &the_cond->Wait_queue, queue_context ); |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief POSIX Condition Variable Allocate |
---|
88 | * |
---|
89 | * This function allocates a condition variable control block from |
---|
90 | * the inactive chain of free condition variable control blocks. |
---|
91 | */ |
---|
92 | RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control * |
---|
93 | _POSIX_Condition_variables_Allocate( void ) |
---|
94 | { |
---|
95 | return (POSIX_Condition_variables_Control *) |
---|
96 | _Objects_Allocate( &_POSIX_Condition_variables_Information ); |
---|
97 | } |
---|
98 | |
---|
99 | /** |
---|
100 | * @brief POSIX Condition Variable Free |
---|
101 | * |
---|
102 | * This routine frees a condition variable control block to the |
---|
103 | * inactive chain of free condition variable control blocks. |
---|
104 | */ |
---|
105 | RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free ( |
---|
106 | POSIX_Condition_variables_Control *the_condition_variable |
---|
107 | ) |
---|
108 | { |
---|
109 | _Objects_Free( |
---|
110 | &_POSIX_Condition_variables_Information, |
---|
111 | &the_condition_variable->Object |
---|
112 | ); |
---|
113 | } |
---|
114 | |
---|
115 | POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get( |
---|
116 | pthread_cond_t *cond, |
---|
117 | Thread_queue_Context *queue_context |
---|
118 | ); |
---|
119 | |
---|
120 | /** |
---|
121 | * @brief Implements wake up version of the "signal" operation. |
---|
122 | * |
---|
123 | * A support routine which implements guts of the broadcast and single task |
---|
124 | * wake up version of the "signal" operation. |
---|
125 | */ |
---|
126 | int _POSIX_Condition_variables_Signal_support( |
---|
127 | pthread_cond_t *cond, |
---|
128 | bool is_broadcast |
---|
129 | ); |
---|
130 | |
---|
131 | /** |
---|
132 | * @brief POSIX condition variables wait support. |
---|
133 | * |
---|
134 | * A support routine which implements guts of the blocking, non-blocking, and |
---|
135 | * timed wait version of condition variable wait routines. |
---|
136 | */ |
---|
137 | int _POSIX_Condition_variables_Wait_support( |
---|
138 | pthread_cond_t *cond, |
---|
139 | pthread_mutex_t *mutex, |
---|
140 | const struct timespec *abstime |
---|
141 | ); |
---|
142 | |
---|
143 | #ifdef __cplusplus |
---|
144 | } |
---|
145 | #endif |
---|
146 | |
---|
147 | #endif |
---|
148 | /* end of include file */ |
---|