source: rtems/cpukit/include/rtems/rtems/semimpl.h @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 2.8 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
59RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations(
60  const Semaphore_Control *the_semaphore
61)
62{
63  if ( the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY ) {
64    return &_Thread_queue_Operations_priority_inherit;
65  }
66
67  if ( the_semaphore->discipline == SEMAPHORE_DISCIPLINE_PRIORITY ) {
68    return &_Thread_queue_Operations_priority;
69  }
70
71  return &_Thread_queue_Operations_FIFO;
72}
73
74/**
75 *  @brief Allocates a semaphore control block from
76 *  the inactive chain of free semaphore control blocks.
77 *
78 *  This function allocates a semaphore control block from
79 *  the inactive chain of free semaphore control blocks.
80 */
81RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void )
82{
83  return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information );
84}
85
86/**
87 *  @brief Frees a semaphore control block to the
88 *  inactive chain of free semaphore control blocks.
89 *
90 *  This routine frees a semaphore control block to the
91 *  inactive chain of free semaphore control blocks.
92 */
93RTEMS_INLINE_ROUTINE void _Semaphore_Free (
94  Semaphore_Control *the_semaphore
95)
96{
97  _Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
98}
99
100RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get(
101  Objects_Id            id,
102  Thread_queue_Context *queue_context
103)
104{
105  _Thread_queue_Context_initialize( queue_context );
106  return (Semaphore_Control *) _Objects_Get(
107    id,
108    &queue_context->Lock_context.Lock_context,
109    &_Semaphore_Information
110  );
111}
112
113/** @} */
114
115#ifdef __cplusplus
116}
117#endif
118
119#ifdef RTEMS_MULTIPROCESSING
120#include <rtems/rtems/semmp.h>
121#endif
122
123#endif
124/*  end of include file */
Note: See TracBrowser for help on using the repository browser.