source: rtems/cpukit/posix/include/rtems/posix/condimpl.h @ 63b36cbf

5
Last change on this file since 63b36cbf was b5bfaaf9, checked in by Gedare Bloom <gedare@…>, on 06/23/16 at 20:55:38

posix: cond_timedwait remember and use clock from condattr

updates #2745

  • Property mode set to 100644
File size: 3.8 KB
Line 
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
27extern "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 0
35
36#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
37
38/**
39 *  The following defines the information control block used to manage
40 *  this class of objects.
41 */
42extern Objects_Information _POSIX_Condition_variables_Information;
43
44/**
45 *  The default condition variable attributes structure.
46 */
47extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes;
48
49RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize(
50  POSIX_Condition_variables_Control *the_cond,
51  pthread_condattr_t *the_attr
52)
53{
54  _Thread_queue_Initialize( &the_cond->Wait_queue );
55  the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
56  the_cond->clock = the_attr->clock;
57}
58
59RTEMS_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
66RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Acquire_critical(
67  POSIX_Condition_variables_Control *the_cond,
68  Thread_queue_Context              *queue_context
69)
70{
71  _Thread_queue_Acquire_critical(
72    &the_cond->Wait_queue,
73    &queue_context->Lock_context
74  );
75}
76
77RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release(
78  POSIX_Condition_variables_Control *the_cond,
79  Thread_queue_Context              *queue_context
80)
81{
82  _Thread_queue_Release( &the_cond->Wait_queue, &queue_context->Lock_context );
83}
84
85/**
86 *  @brief POSIX Condition Variable Allocate
87 *
88 *  This function allocates a condition variable control block from
89 *  the inactive chain of free condition variable control blocks.
90 */
91RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *
92  _POSIX_Condition_variables_Allocate( void )
93{
94  return (POSIX_Condition_variables_Control *)
95    _Objects_Allocate( &_POSIX_Condition_variables_Information );
96}
97
98/**
99 *  @brief POSIX Condition Variable Free
100 *
101 *  This routine frees a condition variable control block to the
102 *  inactive chain of free condition variable control blocks.
103 */
104RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free (
105  POSIX_Condition_variables_Control *the_condition_variable
106)
107{
108  _Objects_Free(
109    &_POSIX_Condition_variables_Information,
110    &the_condition_variable->Object
111  );
112}
113
114POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get(
115  pthread_cond_t       *cond,
116  Thread_queue_Context *queue_context
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 */
125int _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 */
136int _POSIX_Condition_variables_Wait_support(
137  pthread_cond_t            *cond,
138  pthread_mutex_t           *mutex,
139  const struct timespec     *abstime
140);
141
142#ifdef __cplusplus
143}
144#endif
145
146#endif
147/*  end of include file */
Note: See TracBrowser for help on using the repository browser.