source: rtems/cpukit/rtems/include/rtems/rtems/semimpl.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: 2.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicSem
5 *
6 * @brief Classic Semaphores 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/sem.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 * @brief Classic semaphore variants.
31 *
32 * Must be in synchronization with Semaphore_Control::variant.
33 */
34typedef enum {
35  SEMAPHORE_VARIANT_MUTEX,
36  SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL,
37  SEMAPHORE_VARIANT_SIMPLE_BINARY,
38  SEMAPHORE_VARIANT_COUNTING
39#if defined(RTEMS_SMP)
40  ,
41  SEMAPHORE_VARIANT_MRSP
42#endif
43} Semaphore_Variant;
44
45typedef enum {
46  SEMAPHORE_DISCIPLINE_PRIORITY,
47  SEMAPHORE_DISCIPLINE_FIFO
48} Semaphore_Discipline;
49
50/**
51 *  The following defines the information control block used to manage
52 *  this class of objects.
53 */
54extern Objects_Information _Semaphore_Information;
55
56RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations(
57  const Semaphore_Control *the_semaphore
58)
59{
60  if ( the_semaphore->discipline == SEMAPHORE_DISCIPLINE_PRIORITY ) {
61    return &_Thread_queue_Operations_priority;
62  } else {
63    return &_Thread_queue_Operations_FIFO;
64  }
65}
66
67/**
68 *  @brief Allocates a semaphore control block from
69 *  the inactive chain of free semaphore control blocks.
70 *
71 *  This function allocates a semaphore control block from
72 *  the inactive chain of free semaphore control blocks.
73 */
74RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void )
75{
76  return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information );
77}
78
79/**
80 *  @brief Frees a semaphore control block to the
81 *  inactive chain of free semaphore control blocks.
82 *
83 *  This routine frees a semaphore control block to the
84 *  inactive chain of free semaphore control blocks.
85 */
86RTEMS_INLINE_ROUTINE void _Semaphore_Free (
87  Semaphore_Control *the_semaphore
88)
89{
90  _Objects_Free( &_Semaphore_Information, &the_semaphore->Object );
91}
92
93RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get(
94  Objects_Id            id,
95  Thread_queue_Context *queue_context
96)
97{
98  _Thread_queue_Context_initialize( queue_context );
99  return (Semaphore_Control *) _Objects_Get(
100    id,
101    &queue_context->Lock_context,
102    &_Semaphore_Information
103  );
104}
105
106#ifdef __cplusplus
107}
108#endif
109
110#ifdef RTEMS_MULTIPROCESSING
111#include <rtems/rtems/semmp.h>
112#endif
113
114#endif
115/*  end of include file */
Note: See TracBrowser for help on using the repository browser.