OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [include/] [rtems/] [score/] [coremutex.h] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-1999.
9
 *  On-Line Applications Research Corporation (OAR).
10
 *
11
 *  The license and distribution terms for this file may be
12
 *  found in the file LICENSE in this distribution or at
13
 *  http://www.OARcorp.com/rtems/license.html.
14
 *
15
 *  $Id: coremutex.h,v 1.2 2001-09-27 11:59:32 chris Exp $
16
 */
17
 
18
#ifndef __RTEMS_CORE_MUTEX_h
19
#define __RTEMS_CORE_MUTEX_h
20
 
21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24
 
25
#include <rtems/score/thread.h>
26
#include <rtems/score/threadq.h>
27
#include <rtems/score/priority.h>
28
#include <rtems/score/watchdog.h>
29
 
30
/*
31
 *  The following type defines the callout which the API provides
32
 *  to support global/multiprocessor operations on mutexes.
33
 */
34
 
35
typedef void ( *CORE_mutex_API_mp_support_callout )(
36
                 Thread_Control *,
37
                 Objects_Id
38
             );
39
 
40
/*
41
 *  Blocking disciplines for a mutex.
42
 */
43
 
44
typedef enum {
45
  CORE_MUTEX_DISCIPLINES_FIFO,
46
  CORE_MUTEX_DISCIPLINES_PRIORITY,
47
  CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT,
48
  CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING
49
}   CORE_mutex_Disciplines;
50
 
51
/*
52
 *  Mutex handler return statuses.
53
 */
54
 
55
typedef enum {
56
  CORE_MUTEX_STATUS_SUCCESSFUL,
57
  CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT,
58
  CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED,
59
  CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE,
60
  CORE_MUTEX_WAS_DELETED,
61
  CORE_MUTEX_TIMEOUT,
62
  CORE_MUTEX_STATUS_CEILING_VIOLATED
63
}   CORE_mutex_Status;
64
 
65
/*
66
 *  Mutex lock nesting behavior
67
 *
68
 *  CORE_MUTEX_NESTING_ACQUIRES:
69
 *    This sequence has no blocking or errors:
70
 *         lock(m)
71
 *         lock(m)
72
 *         unlock(m)
73
 *         unlock(m)
74
 *
75
 *  CORE_MUTEX_NESTING_IS_ERROR
76
 *    This sequence returns an error at the indicated point:
77
 *        lock(m)
78
 *        lock(m)   - already locked error
79
 *        unlock(m)
80
 *
81
 *  CORE_MUTEX_NESTING_BLOCKS
82
 *    This sequence performs as indicated:
83
 *        lock(m)
84
 *        lock(m)   - deadlocks or timeouts
85
 *        unlock(m) - releases
86
 */
87
 
88
typedef enum {
89
  CORE_MUTEX_NESTING_ACQUIRES,
90
  CORE_MUTEX_NESTING_IS_ERROR,
91
  CORE_MUTEX_NESTING_BLOCKS
92
}  CORE_mutex_Nesting_behaviors;
93
 
94
/*
95
 *  Locked and unlocked values
96
 */
97
 
98
#define CORE_MUTEX_UNLOCKED 1
99
#define CORE_MUTEX_LOCKED   0
100
 
101
/*
102
 *  The following defines the control block used to manage the
103
 *  attributes of each mutex.
104
 */
105
 
106
typedef struct {
107
  CORE_mutex_Nesting_behaviors lock_nesting_behavior;
108
  boolean                      only_owner_release;
109
  CORE_mutex_Disciplines       discipline;
110
  Priority_Control             priority_ceiling;
111
}   CORE_mutex_Attributes;
112
 
113
/*
114
 *  The following defines the control block used to manage each mutex.
115
 */
116
 
117
typedef struct {
118
  Thread_queue_Control    Wait_queue;
119
  CORE_mutex_Attributes   Attributes;
120
  unsigned32              lock;
121
  unsigned32              nest_count;
122
  Thread_Control         *holder;
123
  Objects_Id              holder_id;
124
}   CORE_mutex_Control;
125
 
126
/*
127
 *  _CORE_mutex_Initialize
128
 *
129
 *  DESCRIPTION:
130
 *
131
 *  This routine initializes the mutex based on the parameters passed.
132
 */
133
 
134
void _CORE_mutex_Initialize(
135
  CORE_mutex_Control           *the_mutex,
136
  Objects_Classes               the_class,
137
  CORE_mutex_Attributes        *the_mutex_attributes,
138
  unsigned32                    initial_lock,
139
  Thread_queue_Extract_callout  proxy_extract_callout
140
);
141
 
142
/*
143
 *  _CORE_mutex_Seize
144
 *
145
 *  DESCRIPTION:
146
 *
147
 *  This routine attempts to receive a unit from the_mutex.
148
 *  If a unit is available or if the wait flag is FALSE, then the routine
149
 *  returns.  Otherwise, the calling task is blocked until a unit becomes
150
 *  available.
151
 */
152
 
153
void _CORE_mutex_Seize(
154
  CORE_mutex_Control  *the_mutex,
155
  Objects_Id           id,
156
  boolean              wait,
157
  Watchdog_Interval    timeout
158
);
159
 
160
/*
161
 *  _CORE_mutex_Surrender
162
 *
163
 *  DESCRIPTION:
164
 *
165
 *  This routine frees a unit to the mutex.  If a task was blocked waiting for
166
 *  a unit from this mutex, then that task will be readied and the unit
167
 *  given to that task.  Otherwise, the unit will be returned to the mutex.
168
 */
169
 
170
CORE_mutex_Status _CORE_mutex_Surrender(
171
  CORE_mutex_Control                *the_mutex,
172
  Objects_Id                         id,
173
  CORE_mutex_API_mp_support_callout  api_mutex_mp_support
174
);
175
 
176
/*
177
 *  _CORE_mutex_Flush
178
 *
179
 *  DESCRIPTION:
180
 *
181
 *  This routine assists in the deletion of a mutex by flushing the associated
182
 *  wait queue.
183
 */
184
 
185
void _CORE_mutex_Flush(
186
  CORE_mutex_Control         *the_mutex,
187
  Thread_queue_Flush_callout  remote_extract_callout,
188
  unsigned32                  status
189
);
190
 
191
#ifndef __RTEMS_APPLICATION__
192
#include <rtems/score/coremutex.inl>
193
#endif
194
 
195
#ifdef __cplusplus
196
}
197
#endif
198
 
199
#endif
200
/*  end of include file */
201
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.