1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief CORE Mutex API |
---|
5 | * |
---|
6 | * This include file contains all the constants and structures associated with |
---|
7 | * the Mutex Handler. A mutex is an enhanced version of the standard Dijkstra |
---|
8 | * binary semaphore used to provide synchronization and mutual exclusion |
---|
9 | * capabilities. |
---|
10 | */ |
---|
11 | |
---|
12 | /* |
---|
13 | * COPYRIGHT (c) 1989-2011. |
---|
14 | * On-Line Applications Research Corporation (OAR). |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.org/license/LICENSE. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _RTEMS_SCORE_COREMUTEX_H |
---|
22 | #define _RTEMS_SCORE_COREMUTEX_H |
---|
23 | |
---|
24 | #include <rtems/score/thread.h> |
---|
25 | #include <rtems/score/threadq.h> |
---|
26 | #include <rtems/score/priority.h> |
---|
27 | #include <rtems/score/watchdog.h> |
---|
28 | #include <rtems/score/interr.h> |
---|
29 | |
---|
30 | #ifdef __cplusplus |
---|
31 | extern "C" { |
---|
32 | #endif |
---|
33 | |
---|
34 | /** |
---|
35 | * @defgroup ScoreMutex Mutex Handler |
---|
36 | * |
---|
37 | * @ingroup Score |
---|
38 | * |
---|
39 | * This handler encapsulates functionality which provides the foundation |
---|
40 | * Mutex services used in all of the APIs supported by RTEMS. |
---|
41 | */ |
---|
42 | /**@{*/ |
---|
43 | |
---|
44 | /** |
---|
45 | * @brief Control block used to manage each mutex. |
---|
46 | * |
---|
47 | * The following defines the control block used to manage each mutex. |
---|
48 | */ |
---|
49 | typedef struct { |
---|
50 | /** This field is the Waiting Queue used to manage the set of tasks |
---|
51 | * which are blocked waiting to lock the mutex. |
---|
52 | */ |
---|
53 | Thread_queue_Control Wait_queue; |
---|
54 | |
---|
55 | /** This element points to the thread which is currently holding this mutex. |
---|
56 | * The holder is the last thread to successfully lock the mutex and which |
---|
57 | * has not unlocked it. If the thread is not locked, there is no holder. |
---|
58 | */ |
---|
59 | Thread_Control *holder; |
---|
60 | } CORE_mutex_Control; |
---|
61 | |
---|
62 | /** |
---|
63 | * @brief The recursive mutex control. |
---|
64 | */ |
---|
65 | typedef struct { |
---|
66 | /** |
---|
67 | * @brief The plain non-recursive mutex. |
---|
68 | */ |
---|
69 | CORE_mutex_Control Mutex; |
---|
70 | |
---|
71 | /** |
---|
72 | * @brief The nest level in case of a recursive seize. |
---|
73 | */ |
---|
74 | unsigned int nest_level; |
---|
75 | } CORE_recursive_mutex_Control; |
---|
76 | |
---|
77 | /** |
---|
78 | * @brief The recursive mutex control with priority ceiling protocol support. |
---|
79 | */ |
---|
80 | typedef struct { |
---|
81 | /** |
---|
82 | * @brief The plain recursive mutex. |
---|
83 | */ |
---|
84 | CORE_recursive_mutex_Control Recursive; |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief The priority ceiling value for the mutex owner. |
---|
88 | */ |
---|
89 | Priority_Control priority_ceiling; |
---|
90 | } CORE_ceiling_mutex_Control; |
---|
91 | |
---|
92 | /**@}*/ |
---|
93 | |
---|
94 | #ifdef __cplusplus |
---|
95 | } |
---|
96 | #endif |
---|
97 | |
---|
98 | #endif |
---|
99 | /* end of include file */ |
---|