RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
semimpl.h
Go to the documentation of this file.
1
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>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
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
53
54typedef enum {
55 SEMAPHORE_DISCIPLINE_PRIORITY,
56 SEMAPHORE_DISCIPLINE_FIFO
57} Semaphore_Discipline;
58
59RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Get_flags(
60 const Semaphore_Control *the_semaphore
61)
62{
63 _Assert( _Chain_Is_node_off_chain( &the_semaphore->Object.Node ) );
64 return (uintptr_t) the_semaphore->Object.Node.previous;
65}
66
67RTEMS_INLINE_ROUTINE void _Semaphore_Set_flags(
68 Semaphore_Control *the_semaphore,
69 uintptr_t flags
70)
71{
72 _Assert( _Chain_Is_node_off_chain( &the_semaphore->Object.Node ) );
73 the_semaphore->Object.Node.previous = (Chain_Node *) flags;
74}
75
76RTEMS_INLINE_ROUTINE Semaphore_Variant _Semaphore_Get_variant(
77 uintptr_t flags
78)
79{
80 return (Semaphore_Discipline) ( flags & 0x7 );
81}
82
83RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_variant(
84 uintptr_t flags,
85 Semaphore_Variant variant
86)
87{
88 return flags | variant;
89}
90
91RTEMS_INLINE_ROUTINE Semaphore_Discipline _Semaphore_Get_discipline(
92 uintptr_t flags
93)
94{
95 return (Semaphore_Discipline) ( ( flags >> 3 ) & 0x1 );
96}
97
98RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_discipline(
99 uintptr_t flags,
100 Semaphore_Discipline discipline
101)
102{
103 return flags | ( discipline << 3 );
104}
105
106#if defined(RTEMS_MULTIPROCESSING)
107RTEMS_INLINE_ROUTINE bool _Semaphore_Is_global(
108 uintptr_t flags
109)
110{
111 return ( flags & 0x10 ) != 0;
112}
113
114RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Make_global( uintptr_t flags )
115{
116 return flags | 0x10;
117}
118#endif
119
120RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations(
121 uintptr_t flags
122)
123{
124 if (
125 _Semaphore_Get_variant( flags ) == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
126 ) {
127 return &_Thread_queue_Operations_priority_inherit;
128 }
129
130 if ( _Semaphore_Get_discipline( flags ) == SEMAPHORE_DISCIPLINE_PRIORITY ) {
131 return &_Thread_queue_Operations_priority;
132 }
133
134 return &_Thread_queue_Operations_FIFO;
135}
136
145{
147}
148
157 Semaphore_Control *the_semaphore
158)
159{
160 _Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
161}
162
164 Objects_Id id,
165 Thread_queue_Context *queue_context
166)
167{
168 _Thread_queue_Context_initialize( queue_context );
170 id,
171 &queue_context->Lock_context.Lock_context,
173 );
174}
175
178#ifdef __cplusplus
179}
180#endif
181
182#ifdef RTEMS_MULTIPROCESSING
183#include <rtems/rtems/semmp.h>
184#endif
185
186#endif
187/* end of include file */
CORE Mutex Implementation.
Inlined Routines Associated with the SuperCore Semaphore.
Objects_Information _Semaphore_Information
The Classic Semaphore objects information.
Semaphore_Variant
Classic semaphore variants.
Definition: semimpl.h:42
RTEMS_INLINE_ROUTINE Semaphore_Control * _Semaphore_Allocate(void)
Allocates a semaphore control block from the inactive chain of free semaphore control blocks.
Definition: semimpl.h:144
RTEMS_INLINE_ROUTINE void _Semaphore_Free(Semaphore_Control *the_semaphore)
Frees a semaphore control block to the inactive chain of free semaphore control blocks.
Definition: semimpl.h:156
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain(const Chain_Node *node)
Checks if the node is off chain.
Definition: chainimpl.h:142
RTEMS_INLINE_ROUTINE void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectimpl.h:930
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:42
uint32_t Objects_Id
Definition: object.h:80
Objects_Control * _Objects_Get(Objects_Id id, ISR_lock_Context *lock_context, const Objects_Information *information)
Maps the specified object identifier to the associated local object control block.
Definition: objectgetlocal.c:28
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
Definition: threadqimpl.h:152
Definitions for Multiprocessor Resource Sharing Protocol (MrsP) Implementation.
Classic Semaphore Manager Data Structures.
Definition: chain.h:68
Chain_Node * previous
Definition: chain.h:72
Chain_Node Node
Definition: objectdata.h:41
Definition: semdata.h:40
Objects_Control Object
The object management portion of a semaphore instance.
Definition: semdata.h:50
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
Thread queue operations.
Definition: threadq.h:518