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