source: rtems/cpukit/posix/include/rtems/posix/muteximpl.h @ 5a598ac

5
Last change on this file since 5a598ac was 5a598ac, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 06:02:03

score: Add CORE mutex variants

Add CORE_recursive_mutex_Control and CORE_ceiling_mutex_Control to avoid
the run-time evaluation of attributes to figure out how a particular
mutex methods should behave. Start with the no protocol variants. This
eliminates the CORE_MUTEX_DISCIPLINES_FIFO and
CORE_MUTEX_DISCIPLINES_PRIORITY disciplines.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Private Inlined Routines for POSIX Mutex's.
5 *
6 * This include file contains the static inline implementation of the private
7 * inlined routines for POSIX mutex's.
8 */
9
10/*  COPYRIGHT (c) 1989-2013.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_POSIX_MUTEXIMPL_H
19#define _RTEMS_POSIX_MUTEXIMPL_H
20
21#include <rtems/posix/mutex.h>
22#include <rtems/score/coremuteximpl.h>
23
24#include <errno.h>
25#include <pthread.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
32
33/**
34 * @brief Supported POSIX mutex protocols.
35 *
36 * Must be in synchronization with POSIX_Mutex_Control::protocol.
37 */
38typedef enum {
39  POSIX_MUTEX_NO_PROTOCOL,
40  POSIX_MUTEX_PRIORITY_INHERIT,
41  POSIX_MUTEX_PRIORITY_CEILING
42} POSIX_Mutex_Protocol;
43
44/**
45 *  The following defines the information control block used to manage
46 *  this class of objects.
47 */
48extern Objects_Information _POSIX_Mutex_Information;
49
50/**
51 *  The default mutex attributes structure.
52 */
53extern pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
54
55RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Acquire_critical(
56  POSIX_Mutex_Control  *the_mutex,
57  Thread_queue_Context *queue_context
58)
59{
60  _CORE_mutex_Acquire_critical(
61    &the_mutex->Mutex.Recursive.Mutex,
62    queue_context
63  );
64}
65
66RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release(
67  POSIX_Mutex_Control  *the_mutex,
68  Thread_queue_Context *queue_context
69)
70{
71  _CORE_mutex_Release(
72    &the_mutex->Mutex.Recursive.Mutex,
73    queue_context
74  );
75}
76
77/**
78 *  @brief POSIX Mutex Allocate
79 *
80 *  This function allocates a mutexes control block from
81 *  the inactive chain of free mutexes control blocks.
82 */
83RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Allocate( void )
84{
85  return (POSIX_Mutex_Control *) _Objects_Allocate( &_POSIX_Mutex_Information );
86}
87
88/**
89 *  @brief POSIX Mutex Free
90 *
91 *  This routine frees a mutexes control block to the
92 *  inactive chain of free mutexes control blocks.
93 */
94RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Free(
95  POSIX_Mutex_Control *the_mutex
96)
97{
98  _Objects_Free( &_POSIX_Mutex_Information, &the_mutex->Object );
99}
100
101
102/**
103 *  @brief POSIX Mutex Lock Support Method
104 *
105 *  A support routine which implements guts of the blocking, non-blocking, and
106 *  timed wait version of mutex lock.
107 */
108int _POSIX_Mutex_Lock_support(
109  pthread_mutex_t           *mutex,
110  bool                       blocking,
111  Watchdog_Interval          timeout
112);
113
114/**
115 *  @brief POSIX Mutex Get (Interrupt Disable)
116 *
117 *  A support routine which translates the mutex id into a local pointer.
118 *  As a side-effect, it may create the mutex.
119 *
120 *  @note: This version of the method uses an interrupt critical section.
121 */
122POSIX_Mutex_Control *_POSIX_Mutex_Get(
123  pthread_mutex_t      *mutex,
124  Thread_queue_Context *queue_context
125);
126
127RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get_no_protection(
128  const pthread_mutex_t *mutex
129)
130{
131  return (POSIX_Mutex_Control *) _Objects_Get_no_protection(
132    (Objects_Id) *mutex,
133    &_POSIX_Mutex_Information
134  );
135}
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif
142/*  end of include file */
143
Note: See TracBrowser for help on using the repository browser.