source: rtems/c/src/exec/score/include/rtems/score/coremutex.h @ 1a8fde6c

4.104.114.84.95
Last change on this file since 1a8fde6c was 1a8fde6c, checked in by Joel Sherrill <joel.sherrill@…>, on 03/06/96 at 21:34:57

Removed prototyes for static inline routines and moved the comments into
the inline implementation. The impetus for this was twofold. First,
it is incorrect to have static inline prototypes when using the macro
implementation. Second, this reduced the number of lines in the include
files seen by rtems.h by about 2000 lines.

Next we restricted visibility for the inline routines to inside the
executive itself EXCEPT for a handful of objects. This reduced the
number of include files included by rtems.h by 40 files and reduced
the lines in the include files seen by rtems.h by about 6000 lines.

In total, these reduced the compile time of the entire RTEMS tree by 20%.
This results in about 8 minutes savings on the SparcStation? 10 morgana.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*  mutex.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Mutex Handler.  A mutex is an enhanced version of the standard
5 *  Dijkstra binary semaphore used to provide synchronization and mutual
6 *  exclusion capabilities.
7 *
8 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
9 *  On-Line Applications Research Corporation (OAR).
10 *  All rights assigned to U.S. Government, 1994.
11 *
12 *  This material may be reproduced by or for the U.S. Government pursuant
13 *  to the copyright license under the clause at DFARS 252.227-7013.  This
14 *  notice must appear in all copies of this file and its derivatives.
15 *
16 *  $Id$
17 */
18 
19#ifndef __RTEMS_CORE_MUTEX_h
20#define __RTEMS_CORE_MUTEX_h
21 
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <rtems/score/thread.h>
27#include <rtems/score/threadq.h>
28#include <rtems/score/priority.h>
29#include <rtems/score/watchdog.h>
30 
31/*
32 *  The following type defines the callout which the API provides
33 *  to support global/multiprocessor operations on mutexes.
34 */
35 
36typedef void ( *CORE_mutex_API_mp_support_callout )(
37                 Thread_Control *,
38                 Objects_Id
39             );
40
41/*
42 *  Blocking disciplines for a mutex.
43 */
44
45typedef enum {
46  CORE_MUTEX_DISCIPLINES_FIFO,
47  CORE_MUTEX_DISCIPLINES_PRIORITY,
48  CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT,
49  CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING
50}   CORE_mutex_Disciplines;
51
52/*
53 *  Mutex handler return statuses.
54 */
55 
56typedef enum {
57  CORE_MUTEX_STATUS_SUCCESSFUL,
58  CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT,
59  CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED,
60  CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE,
61  CORE_MUTEX_WAS_DELETED,
62  CORE_MUTEX_TIMEOUT
63}   CORE_mutex_Status;
64
65/*
66 *  Locked and unlocked values
67 */
68
69#define CORE_MUTEX_UNLOCKED 1
70#define CORE_MUTEX_LOCKED   0
71
72/*
73 *  The following defines the control block used to manage the
74 *  attributes of each mutex.
75 */
76
77typedef struct {
78  boolean                 allow_nesting;
79  CORE_mutex_Disciplines  discipline;
80  Priority_Control        priority_ceiling;
81}   CORE_mutex_Attributes;
82 
83/*
84 *  The following defines the control block used to manage each mutex.
85 */
86 
87typedef struct {
88  Thread_queue_Control    Wait_queue;
89  CORE_mutex_Attributes   Attributes;
90  unsigned32              lock;
91  unsigned32              nest_count;
92  Thread_Control         *holder;
93  Objects_Id              holder_id;
94}   CORE_mutex_Control;
95
96/*
97 *  _CORE_mutex_Initialize
98 *
99 *  DESCRIPTION:
100 *
101 *  This routine initializes the mutex based on the parameters passed.
102 */
103
104void _CORE_mutex_Initialize(
105  CORE_mutex_Control           *the_mutex,
106  Objects_Classes               the_class,
107  CORE_mutex_Attributes        *the_mutex_attributes,
108  unsigned32                    initial_lock,
109  Thread_queue_Extract_callout  proxy_extract_callout
110);
111 
112/*
113 *  _CORE_mutex_Seize
114 *
115 *  DESCRIPTION:
116 *
117 *  This routine attempts to receive a unit from the_mutex.
118 *  If a unit is available or if the wait flag is FALSE, then the routine
119 *  returns.  Otherwise, the calling task is blocked until a unit becomes
120 *  available.
121 */
122
123void _CORE_mutex_Seize(
124  CORE_mutex_Control  *the_mutex,
125  Objects_Id           id,
126  boolean              wait,
127  Watchdog_Interval    timeout
128);
129 
130/*
131 *  _CORE_mutex_Surrender
132 *
133 *  DESCRIPTION:
134 *
135 *  This routine frees a unit to the mutex.  If a task was blocked waiting for
136 *  a unit from this mutex, then that task will be readied and the unit
137 *  given to that task.  Otherwise, the unit will be returned to the mutex.
138 */
139
140CORE_mutex_Status _CORE_mutex_Surrender(
141  CORE_mutex_Control                *the_mutex,
142  Objects_Id                         id,
143  CORE_mutex_API_mp_support_callout  api_mutex_mp_support
144);
145 
146/*
147 *  _CORE_mutex_Flush
148 *
149 *  DESCRIPTION:
150 *
151 *  This routine assists in the deletion of a mutex by flushing the associated
152 *  wait queue.
153 */
154 
155void _CORE_mutex_Flush(
156  CORE_mutex_Control         *the_mutex,
157  Thread_queue_Flush_callout  remote_extract_callout,
158  unsigned32                  status
159);
160 
161#ifndef __RTEMS_APPLICATION__
162#include <rtems/score/coremutex.inl>
163#endif
164
165#ifdef __cplusplus
166}
167#endif
168 
169#endif
170/*  end of include file */
171
Note: See TracBrowser for help on using the repository browser.