source: rtems/cpukit/score/include/rtems/score/apimutex.h @ ef9505a9

4.104.114.84.95
Last change on this file since ef9505a9 was ef9505a9, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 1, 2002 at 10:30:12 PM

2002-07-01 Joel Sherrill <joel@…>

  • Mega patch merge to change the format of the object IDs to loosen the dependency between the SCORE and the various APIs. There was considerable work to simplify the object name management and it appears that the name_table field is no longer needed. This patch also includes the addition of the internal mutex which is currently only used to protect some types of allocation and deallocation. This significantly can reduce context switch latency under certain circumstances. In particular, some heap/region operations were O(n) and had dispatching disabled. This should help enormously. With this merge, the patch is not as clean as it should be. In particular, the documentation has not been modified to reflect the new object ID layout, the IDs in the test screens are not updated, and _Objects_Get_information needs to be a real routine not inlined. As part of this patch a lot of MP code for thread/proxy blocking was made conditional and cleaned up.
  • include/Makefile.am, include/rtems/score/coremsg.h, include/rtems/score/coremutex.h, include/rtems/score/coresem.h, include/rtems/score/object.h, include/rtems/score/threadq.h, inline/rtems/score/object.inl, inline/rtems/score/thread.inl, macros/rtems/score/object.inl, src/Makefile.am, src/coremsg.c, src/coremutex.c, src/coresem.c, src/mpci.c, src/objectcomparenameraw.c, src/objectextendinformation.c, src/objectinitializeinformation.c, src/objectnametoid.c, src/thread.c, src/threadclose.c, src/threadget.c, src/threadq.c, src/threadqextractwithproxy.c: Modified as part of above.
  • include/rtems/score/apimutex.h, src/objectgetnoprotection.c: New files.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*  apimutex.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the API Mutex Handler.  This handler is used by API level
5 *  routines to manage mutual exclusion.
6 *
7 *  COPYRIGHT (c) 1989-2002.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#ifndef __API_MUTEX_h
18#define __API_MUTEX_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <rtems/score/coremutex.h>
25#include <rtems/score/isr.h>
26#include <rtems/score/object.h>
27
28/*
29 *  The following defines the control block used to manage each mutex.
30 */
31
32typedef struct {
33  Objects_Control       Object;
34  CORE_mutex_Control    Mutex;
35}   API_Mutex_Control;
36
37/*
38 *  The following defines the information control block used to manage
39 *  this class of objects.
40 */
41
42SCORE_EXTERN Objects_Information  _API_Mutex_Information;
43
44/*
45 *  _API_Mutex_Initialization
46 *
47 *  DESCRIPTION:
48 *
49 *  This routine performs the initialization necessary for this handler.
50 */
51
52#if defined(RTEMS_MULTIPROCESSING)
53#define _API_Mutex_Initialization( _maximum_mutexes ) \
54  _Objects_Initialize_information( \
55    &_API_Mutex_Information, \
56    OBJECTS_INTERNAL_API, \
57    OBJECTS_INTERNAL_MUTEXES, \
58    _maximum_mutexes, \
59    sizeof( API_Mutex_Control ), \
60    FALSE, \
61    0, \
62    FALSE, \
63    NULL \
64  );
65#else
66#define _API_Mutex_Initialization( _maximum_mutexes ) \
67  _Objects_Initialize_information( \
68    &_API_Mutex_Information, \
69    OBJECTS_INTERNAL_API, \
70    OBJECTS_INTERNAL_MUTEXES, \
71    _maximum_mutexes, \
72    sizeof( API_Mutex_Control ), \
73    FALSE, \
74    0  \
75  );
76#endif
77
78/*
79 *  _API_Mutex_Allocate
80 *
81 *  DESCRIPTION:
82 *
83 *  This routine allocates an api mutex from the inactive set.
84 */
85
86#define _API_Mutex_Allocate( _the_mutex ) \
87  do { \
88    CORE_mutex_Attributes attr =  \
89      { CORE_MUTEX_NESTING_IS_ERROR, FALSE, \
90        CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT, 0 }; \
91    (_the_mutex) = (API_Mutex_Control *) \
92      _Objects_Allocate( &_API_Mutex_Information ); \
93    _CORE_mutex_Initialize( \
94       &(_the_mutex)->Mutex, &attr, CORE_MUTEX_UNLOCKED ); \
95  } while (0)
96
97/*
98 *  _API_Mutex_Lock
99 *
100 *  DESCRIPTION:
101 *
102 *  This routine acquires the specified api mutex.
103 */
104
105#define _API_Mutex_Lock( _the_mutex ) \
106  do { \
107    ISR_Level _level;  \
108    _CORE_mutex_Seize( \
109      &(_the_mutex)->Mutex, (_the_mutex)->Object.id, TRUE, 0, (_level) ); \
110  } while (0)
111 
112/*
113 *  _API_Mutex_Unlock
114 *
115 *  DESCRIPTION:
116 *
117 *  This routine releases the specified api mutex.
118 */
119
120#define _API_Mutex_Unlock( _the_mutex ) \
121  do { \
122    _Thread_Disable_dispatch(); \
123      _CORE_mutex_Surrender( \
124        &(_the_mutex)->Mutex, (_the_mutex)->Object.id, NULL ); \
125    _Thread_Enable_dispatch(); \
126  } while (0);
127
128/*XXX when the APIs all use this for allocation and deallocation
129 *XXX protection, then they should be renamed and probably moved
130 */
131
132SCORE_EXTERN API_Mutex_Control  *_RTEMS_Allocator_Mutex;
133
134#define _RTEMS_Lock_allocator() \
135  _API_Mutex_Lock( _RTEMS_Allocator_Mutex )
136
137#define _RTEMS_Unlock_allocator() \
138  _API_Mutex_Unlock( _RTEMS_Allocator_Mutex )
139
140/*
141 *  There are no inlines for this handler.
142 */
143
144#ifndef __RTEMS_APPLICATION__
145/* #include <rtems/score/apimutex.inl> */
146#endif
147
148#ifdef __cplusplus
149}
150#endif
151
152#endif
153/*  end of include file */
Note: See TracBrowser for help on using the repository browser.