source: rtems/c/src/exec/score/headers/coresem.h @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

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