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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [include/] [rtems/] [score/] [coresem.h] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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: coresem.h,v 1.2 2001-09-27 11:59:32 chris 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
  Objects_Classes               the_class,
93
  CORE_semaphore_Attributes    *the_semaphore_attributes,
94
  unsigned32                    initial_value,
95
  Thread_queue_Extract_callout  proxy_extract_callout
96
);
97
 
98
/*
99
 *  _CORE_semaphore_Seize
100
 *
101
 *  DESCRIPTION:
102
 *
103
 *  This routine attempts to receive a unit from the_semaphore.
104
 *  If a unit is available or if the wait flag is FALSE, then the routine
105
 *  returns.  Otherwise, the calling task is blocked until a unit becomes
106
 *  available.
107
 */
108
 
109
void _CORE_semaphore_Seize(
110
  CORE_semaphore_Control  *the_semaphore,
111
  Objects_Id               id,
112
  boolean                  wait,
113
  Watchdog_Interval        timeout
114
);
115
 
116
/*
117
 *  _CORE_semaphore_Surrender
118
 *
119
 *  DESCRIPTION:
120
 *
121
 *  This routine frees a unit to the semaphore.  If a task was blocked waiting
122
 *  for a unit from this semaphore, then that task will be readied and the unit
123
 *  given to that task.  Otherwise, the unit will be returned to the semaphore.
124
 */
125
 
126
CORE_semaphore_Status _CORE_semaphore_Surrender(
127
  CORE_semaphore_Control                *the_semaphore,
128
  Objects_Id                             id,
129
  CORE_semaphore_API_mp_support_callout  api_semaphore_mp_support
130
);
131
 
132
/*
133
 *  _CORE_semaphore_Flush
134
 *
135
 *  DESCRIPTION:
136
 *
137
 *  This routine assists in the deletion of a semaphore by flushing the
138
 *  associated wait queue.
139
 */
140
 
141
void _CORE_semaphore_Flush(
142
  CORE_semaphore_Control         *the_semaphore,
143
  Thread_queue_Flush_callout      remote_extract_callout,
144
  unsigned32                      status
145
);
146
 
147
#ifndef __RTEMS_APPLICATION__
148
#include <rtems/score/coresem.inl>
149
#endif
150
 
151
#ifdef __cplusplus
152
}
153
#endif
154
 
155
#endif
156
/*  end of include file */
157
 

powered by: WebSVN 2.1.0

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