source: rtems/c/src/exec/score/include/rtems/score/coresem.h @ ef9505a9

4.104.114.84.95
Last change on this file since ef9505a9 was ef9505a9, checked in by Joel Sherrill <joel.sherrill@…>, on 07/01/02 at 22:30:12

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.7 KB
Line 
1/*  core_sem.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Counting Semaphore Handler.  A counting semaphore is the
5 *  standard Dijkstra binary semaphore used to provide synchronization
6 *  and mutual 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$
16 */
17 
18#ifndef __RTEMS_CORE_COUNTING_SEMAPHORE_h
19#define __RTEMS_CORE_COUNTING_SEMAPHORE_h
20 
21#ifdef __cplusplus
22extern "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 semaphores.
33 */
34 
35typedef void ( *CORE_semaphore_API_mp_support_callout )(
36                 Thread_Control *,
37                 Objects_Id
38             );
39
40/*
41 *  Blocking disciplines for a semaphore.
42 */
43
44typedef enum {
45  CORE_SEMAPHORE_DISCIPLINES_FIFO,
46  CORE_SEMAPHORE_DISCIPLINES_PRIORITY
47}   CORE_semaphore_Disciplines;
48
49/*
50 *  Core Semaphore handler return statuses.
51 */
52 
53typedef enum {
54  CORE_SEMAPHORE_STATUS_SUCCESSFUL,
55  CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT,
56  CORE_SEMAPHORE_WAS_DELETED,
57  CORE_SEMAPHORE_TIMEOUT,
58  CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
59}   CORE_semaphore_Status;
60
61/*
62 *  The following defines the control block used to manage the
63 *  attributes of each semaphore.
64 */
65
66typedef struct {
67  unsigned32                  maximum_count;
68  CORE_semaphore_Disciplines  discipline;
69}   CORE_semaphore_Attributes;
70 
71/*
72 *  The following defines the control block used to manage each
73 *  counting semaphore.
74 */
75 
76typedef struct {
77  Thread_queue_Control        Wait_queue;
78  CORE_semaphore_Attributes   Attributes;
79  unsigned32                  count;
80}   CORE_semaphore_Control;
81
82/*
83 *  _CORE_semaphore_Initialize
84 *
85 *  DESCRIPTION:
86 *
87 *  This routine initializes the semaphore based on the parameters passed.
88 */
89
90void _CORE_semaphore_Initialize(
91  CORE_semaphore_Control       *the_semaphore,
92  CORE_semaphore_Attributes    *the_semaphore_attributes,
93  unsigned32                    initial_value
94);
95 
96/*
97 *  _CORE_semaphore_Seize
98 *
99 *  DESCRIPTION:
100 *
101 *  This routine attempts to receive a unit from the_semaphore.
102 *  If a unit is available or if the wait flag is FALSE, then the routine
103 *  returns.  Otherwise, the calling task is blocked until a unit becomes
104 *  available.
105 */
106
107void _CORE_semaphore_Seize(
108  CORE_semaphore_Control  *the_semaphore,
109  Objects_Id               id,
110  boolean                  wait,
111  Watchdog_Interval        timeout
112);
113 
114/*
115 *  _CORE_semaphore_Surrender
116 *
117 *  DESCRIPTION:
118 *
119 *  This routine frees a unit to the semaphore.  If a task was blocked waiting
120 *  for a unit from this semaphore, then that task will be readied and the unit
121 *  given to that task.  Otherwise, the unit will be returned to the semaphore.
122 */
123
124CORE_semaphore_Status _CORE_semaphore_Surrender(
125  CORE_semaphore_Control                *the_semaphore,
126  Objects_Id                             id,
127  CORE_semaphore_API_mp_support_callout  api_semaphore_mp_support
128);
129 
130/*
131 *  _CORE_semaphore_Flush
132 *
133 *  DESCRIPTION:
134 *
135 *  This routine assists in the deletion of a semaphore by flushing the
136 *  associated wait queue.
137 */
138
139void _CORE_semaphore_Flush(
140  CORE_semaphore_Control         *the_semaphore,
141  Thread_queue_Flush_callout      remote_extract_callout,
142  unsigned32                      status
143);
144
145#ifndef __RTEMS_APPLICATION__
146#include <rtems/score/coresem.inl>
147#endif
148
149#ifdef __cplusplus
150}
151#endif
152 
153#endif
154/*  end of include file */
155
Note: See TracBrowser for help on using the repository browser.