summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/coremutex.h
blob: 2f65d6c8c04cc2d7ca1a9df33587f1911f6ff444 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
 * @file
 *
 * @ingroup RTEMSScoreMutex
 *
 * @brief This header file provides interfaces of the
 *   @ref RTEMSScoreMutex which are used by the implementation and the
 *   @ref RTEMSImplApplConfig.
 */

/*
 *  COPYRIGHT (c) 1989-2011.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#ifndef _RTEMS_SCORE_COREMUTEX_H
#define _RTEMS_SCORE_COREMUTEX_H

#include <rtems/score/thread.h>
#include <rtems/score/threadq.h>
#include <rtems/score/priority.h>
#include <rtems/score/watchdog.h>
#include <rtems/score/interr.h>

struct _Scheduler_Control;

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @defgroup RTEMSScoreMutex Mutex Handler
 *
 * @ingroup RTEMSScore
 *
 * @brief This group contains the Mutex Handler implementation.
 *
 * This handler encapsulates functionality which provides the foundation
 * Mutex services used in all of the APIs supported by RTEMS.  A mutex is an
 * enhanced version of the standard Dijkstra binary semaphore used to provide
 * synchronization and mutual exclusion capabilities.
 *
 * @{
 */

/**
 *  @brief Control block used to manage each mutex.
 *
 *  The following defines the control block used to manage each mutex.
 */
typedef struct {
  /**
   * @brief The thread queue of this mutex.
   *
   * The owner of the thread queue indicates the mutex owner.
   */
  Thread_queue_Control Wait_queue;
} CORE_mutex_Control;

/**
 * @brief The recursive mutex control.
 */
typedef struct {
  /**
   * @brief The plain non-recursive mutex.
   */
  CORE_mutex_Control Mutex;

  /**
   * @brief The nest level in case of a recursive seize.
   */
  unsigned int nest_level;
} CORE_recursive_mutex_Control;

/**
 * @brief The recursive mutex control with priority ceiling protocol support.
 */
typedef struct {
  /**
   * @brief The plain recursive mutex.
   */
  CORE_recursive_mutex_Control Recursive;

  /**
   * @brief The priority ceiling node for the mutex owner.
   */
  Priority_Node Priority_ceiling;

#if defined(RTEMS_SMP)
  /**
   * @brief The scheduler instance for this priority ceiling mutex.
   */
  const struct _Scheduler_Control *scheduler;
#endif
} CORE_ceiling_mutex_Control;

/** @} */

#ifdef __cplusplus
}
#endif

#endif
/*  end of include file */