source: rtems/cpukit/posix/include/rtems/posix/condimpl.h @ 127c20e

Last change on this file since 127c20e was 127c20e, checked in by Gedare Bloom <gedare@…>, on Jun 23, 2016 at 8:10:39 PM

posix: refactor cond wait support to defer abstime conversion

updates #2745

  • Property mode set to 100644
File size: 3.7 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)
52{
53  _Thread_queue_Initialize( &the_cond->Wait_queue );
54  the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
55}
56
57RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Destroy(
58  POSIX_Condition_variables_Control *the_cond
59)
60{
61  _Thread_queue_Destroy( &the_cond->Wait_queue );
62}
63
64RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Acquire_critical(
65  POSIX_Condition_variables_Control *the_cond,
66  Thread_queue_Context              *queue_context
67)
68{
69  _Thread_queue_Acquire_critical(
70    &the_cond->Wait_queue,
71    &queue_context->Lock_context
72  );
73}
74
75RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release(
76  POSIX_Condition_variables_Control *the_cond,
77  Thread_queue_Context              *queue_context
78)
79{
80  _Thread_queue_Release( &the_cond->Wait_queue, &queue_context->Lock_context );
81}
82
83/**
84 *  @brief POSIX Condition Variable Allocate
85 *
86 *  This function allocates a condition variable control block from
87 *  the inactive chain of free condition variable control blocks.
88 */
89RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *
90  _POSIX_Condition_variables_Allocate( void )
91{
92  return (POSIX_Condition_variables_Control *)
93    _Objects_Allocate( &_POSIX_Condition_variables_Information );
94}
95
96/**
97 *  @brief POSIX Condition Variable Free
98 *
99 *  This routine frees a condition variable control block to the
100 *  inactive chain of free condition variable control blocks.
101 */
102RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free (
103  POSIX_Condition_variables_Control *the_condition_variable
104)
105{
106  _Objects_Free(
107    &_POSIX_Condition_variables_Information,
108    &the_condition_variable->Object
109  );
110}
111
112POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get(
113  pthread_cond_t       *cond,
114  Thread_queue_Context *queue_context
115);
116
117/**
118 * @brief Implements wake up version of the "signal" operation.
119 *
120 * A support routine which implements guts of the broadcast and single task
121 * wake up version of the "signal" operation.
122 */
123int _POSIX_Condition_variables_Signal_support(
124  pthread_cond_t            *cond,
125  bool                       is_broadcast
126);
127
128/**
129 * @brief POSIX condition variables wait support.
130 *
131 * A support routine which implements guts of the blocking, non-blocking, and
132 * timed wait version of condition variable wait routines.
133 */
134int _POSIX_Condition_variables_Wait_support(
135  pthread_cond_t            *cond,
136  pthread_mutex_t           *mutex,
137  const struct timespec     *abstime
138);
139
140#ifdef __cplusplus
141}
142#endif
143
144#endif
145/*  end of include file */
Note: See TracBrowser for help on using the repository browser.