source: rtems/c/src/exec/score/headers/coremutex.h @ 9db72b4

4.104.114.84.95
Last change on this file since 9db72b4 was 03f2154e, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/97 at 17:20:27

headers updated to reflect new style copyright notice as part
of switching to the modified GNU GPL.

  • Property mode set to 100644
File size: 4.0 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-1997.
9 *  On-Line Applications Research Corporation (OAR).
10 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may in
13 *  the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
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_CEILING_VIOLATED
64}   CORE_mutex_Status;
65
66/*
67 *  Locked and unlocked values
68 */
69
70#define CORE_MUTEX_UNLOCKED 1
71#define CORE_MUTEX_LOCKED   0
72
73/*
74 *  The following defines the control block used to manage the
75 *  attributes of each mutex.
76 */
77
78typedef struct {
79  boolean                 allow_nesting;
80  CORE_mutex_Disciplines  discipline;
81  Priority_Control        priority_ceiling;
82}   CORE_mutex_Attributes;
83 
84/*
85 *  The following defines the control block used to manage each mutex.
86 */
87 
88typedef struct {
89  Thread_queue_Control    Wait_queue;
90  CORE_mutex_Attributes   Attributes;
91  unsigned32              lock;
92  unsigned32              nest_count;
93  Thread_Control         *holder;
94  Objects_Id              holder_id;
95}   CORE_mutex_Control;
96
97/*
98 *  _CORE_mutex_Initialize
99 *
100 *  DESCRIPTION:
101 *
102 *  This routine initializes the mutex based on the parameters passed.
103 */
104
105void _CORE_mutex_Initialize(
106  CORE_mutex_Control           *the_mutex,
107  Objects_Classes               the_class,
108  CORE_mutex_Attributes        *the_mutex_attributes,
109  unsigned32                    initial_lock,
110  Thread_queue_Extract_callout  proxy_extract_callout
111);
112 
113/*
114 *  _CORE_mutex_Seize
115 *
116 *  DESCRIPTION:
117 *
118 *  This routine attempts to receive a unit from the_mutex.
119 *  If a unit is available or if the wait flag is FALSE, then the routine
120 *  returns.  Otherwise, the calling task is blocked until a unit becomes
121 *  available.
122 */
123
124void _CORE_mutex_Seize(
125  CORE_mutex_Control  *the_mutex,
126  Objects_Id           id,
127  boolean              wait,
128  Watchdog_Interval    timeout
129);
130 
131/*
132 *  _CORE_mutex_Surrender
133 *
134 *  DESCRIPTION:
135 *
136 *  This routine frees a unit to the mutex.  If a task was blocked waiting for
137 *  a unit from this mutex, then that task will be readied and the unit
138 *  given to that task.  Otherwise, the unit will be returned to the mutex.
139 */
140
141CORE_mutex_Status _CORE_mutex_Surrender(
142  CORE_mutex_Control                *the_mutex,
143  Objects_Id                         id,
144  CORE_mutex_API_mp_support_callout  api_mutex_mp_support
145);
146 
147/*
148 *  _CORE_mutex_Flush
149 *
150 *  DESCRIPTION:
151 *
152 *  This routine assists in the deletion of a mutex by flushing the associated
153 *  wait queue.
154 */
155 
156void _CORE_mutex_Flush(
157  CORE_mutex_Control         *the_mutex,
158  Thread_queue_Flush_callout  remote_extract_callout,
159  unsigned32                  status
160);
161 
162#ifndef __RTEMS_APPLICATION__
163#include <rtems/score/coremutex.inl>
164#endif
165
166#ifdef __cplusplus
167}
168#endif
169 
170#endif
171/*  end of include file */
172
Note: See TracBrowser for help on using the repository browser.