source: rtems/cpukit/score/include/rtems/score/coresem.h @ 8f0529f

4.104.114.84.95
Last change on this file since 8f0529f was 8f0529f, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 15:58:09

Added maximum count detection logic.

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