source: rtems/cpukit/score/include/rtems/score/coresem.h @ d6154c7

4.104.114.84.95
Last change on this file since d6154c7 was d6154c7, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 29, 2004 at 4:41:13 PM

2004-03-29 Ralf Corsepius <ralf_corsepius@…>

  • score/include/rtems/debug.h, score/include/rtems/score/bitfield.h, score/include/rtems/score/chain.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h, score/include/rtems/score/heap.h, score/include/rtems/score/interr.h, score/include/rtems/score/isr.h, score/include/rtems/score/mpci.h, score/include/rtems/score/mppkt.h, score/include/rtems/score/object.h, score/include/rtems/score/objectmp.h, score/include/rtems/score/priority.h, score/include/rtems/score/stack.h, score/include/rtems/score/states.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadmp.h, score/include/rtems/score/threadq.h, score/include/rtems/score/tod.h, score/include/rtems/score/tqdata.h, score/include/rtems/score/userext.h, score/include/rtems/score/watchdog.h, score/include/rtems/score/wkspace.h, score/inline/rtems/score/address.inl, score/inline/rtems/score/coremsg.inl, score/inline/rtems/score/coresem.inl, score/inline/rtems/score/heap.inl, score/inline/rtems/score/isr.inl, score/inline/rtems/score/object.inl, score/inline/rtems/score/priority.inl, score/inline/rtems/score/stack.inl, score/inline/rtems/score/thread.inl, score/inline/rtems/score/tqdata.inl, score/inline/rtems/score/userext.inl, score/inline/rtems/score/wkspace.inl, score/macros/rtems/score/address.inl, score/macros/rtems/score/heap.inl, score/macros/rtems/score/object.inl, score/macros/rtems/score/priority.inl, score/macros/rtems/score/userext.inl: Convert to using c99 fixed size types.
  • 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.rtems.com/license/LICENSE.
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  uint32_t                    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  uint32_t                    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  uint32_t                      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  uint32_t                        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.