source: rtems/cpukit/include/rtems/rtems/semimpl.h @ b7af3e44

5
Last change on this file since b7af3e44 was 739df1f5, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/18 at 09:45:44

rtems: Move internal structures to semdata.h

Update #3598.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicSemImpl
5 *
6 * @brief Classic Semaphore Manager Implementation
7 */
8
9/*  COPYRIGHT (c) 1989-2008.
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_RTEMS_SEMIMPL_H
18#define _RTEMS_RTEMS_SEMIMPL_H
19
20#include <rtems/rtems/semdata.h>
21#include <rtems/score/coremuteximpl.h>
22#include <rtems/score/coresemimpl.h>
23#include <rtems/score/mrspimpl.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * @defgroup ClassicSemImpl Semaphore Manager Implementation
31 *
32 * @ingroup ClassicSem
33 *
34 * @{
35 */
36
37/**
38 * @brief Classic semaphore variants.
39 *
40 * Must be in synchronization with Semaphore_Control::variant.
41 */
42typedef enum {
43  SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY,
44  SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING,
45  SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL,
46  SEMAPHORE_VARIANT_SIMPLE_BINARY,
47  SEMAPHORE_VARIANT_COUNTING
48#if defined(RTEMS_SMP)
49  ,
50  SEMAPHORE_VARIANT_MRSP
51#endif
52} Semaphore_Variant;
53
54typedef enum {
55  SEMAPHORE_DISCIPLINE_PRIORITY,
56  SEMAPHORE_DISCIPLINE_FIFO
57} Semaphore_Discipline;
58
59/**
60 *  The following defines the information control block used to manage
61 *  this class of objects.
62 */
63extern Objects_Information _Semaphore_Information;
64
65RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations(
66  const Semaphore_Control *the_semaphore
67)
68{
69  if ( the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY ) {
70    return &_Thread_queue_Operations_priority_inherit;
71  }
72
73  if ( the_semaphore->discipline == SEMAPHORE_DISCIPLINE_PRIORITY ) {
74    return &_Thread_queue_Operations_priority;
75  }
76
77  return &_Thread_queue_Operations_FIFO;
78}
79
80/**
81 *  @brief Allocates a semaphore control block from
82 *  the inactive chain of free semaphore control blocks.
83 *
84 *  This function allocates a semaphore control block from
85 *  the inactive chain of free semaphore control blocks.
86 */
87RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void )
88{
89  return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information );
90}
91
92/**
93 *  @brief Frees a semaphore control block to the
94 *  inactive chain of free semaphore control blocks.
95 *
96 *  This routine frees a semaphore control block to the
97 *  inactive chain of free semaphore control blocks.
98 */
99RTEMS_INLINE_ROUTINE void _Semaphore_Free (
100  Semaphore_Control *the_semaphore
101)
102{
103  _Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
104}
105
106RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get(
107  Objects_Id            id,
108  Thread_queue_Context *queue_context
109)
110{
111  _Thread_queue_Context_initialize( queue_context );
112  return (Semaphore_Control *) _Objects_Get(
113    id,
114    &queue_context->Lock_context.Lock_context,
115    &_Semaphore_Information
116  );
117}
118
119/** @} */
120
121#ifdef __cplusplus
122}
123#endif
124
125#ifdef RTEMS_MULTIPROCESSING
126#include <rtems/rtems/semmp.h>
127#endif
128
129#endif
130/*  end of include file */
Note: See TracBrowser for help on using the repository browser.