OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [score/] [include/] [rtems/] [score/] [coresem.h] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*  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
 *  coresem.h,v 1.10 2002/07/01 22:30:12 joel Exp
16
 */
17
 
18
#ifndef __RTEMS_CORE_COUNTING_SEMAPHORE_h
19
#define __RTEMS_CORE_COUNTING_SEMAPHORE_h
20
 
21
#ifdef __cplusplus
22
extern "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
 
35
typedef void ( *CORE_semaphore_API_mp_support_callout )(
36
                 Thread_Control *,
37
                 Objects_Id
38
             );
39
 
40
/*
41
 *  Blocking disciplines for a semaphore.
42
 */
43
 
44
typedef 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
 
53
typedef 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
 
66
typedef 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
 
76
typedef 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
 
90
void _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
 
107
void _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
 
124
CORE_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
 
139
void _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
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.