summaryrefslogtreecommitdiffstats
path: root/c/src/exec/score/include/rtems/score/priority.h
blob: 8f681c0ce1ffcc6555833857a71c31b4e924b419 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*  priority.h
 *
 *  This include file contains all thread priority manipulation routines.
 *  This Handler provides mechanisms which can be used to
 *  initialize and manipulate thread priorities.
 *
 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
 *  On-Line Applications Research Corporation (OAR).
 *  All rights assigned to U.S. Government, 1994.
 *
 *  This material may be reproduced by or for the U.S. Government pursuant
 *  to the copyright license under the clause at DFARS 252.227-7013.  This
 *  notice must appear in all copies of this file and its derivatives.
 *
 *  $Id$
 */

#ifndef __PRIORITY_h
#define __PRIORITY_h

#ifdef __cplusplus
extern "C" {
#endif

/*
 *  The following type defines the control block used to manage
 *  thread priorities.
 *
 *  NOTE: Priority 0 is reserved for internal threads only.
 */

typedef unsigned32 Priority_Control;

#define PRIORITY_MINIMUM      0         /* highest thread priority */
#define PRIORITY_MAXIMUM      255       /* lowest thread priority */

/*
 *  The following record defines the information associated with
 *  each thread to manage its interaction with the priority bit maps.
 */

typedef struct {
  Priority_Bit_map_control *minor;        /* addr of minor bit map slot */
  Priority_Bit_map_control  ready_major;  /* priority bit map ready mask */
  Priority_Bit_map_control  ready_minor;  /* priority bit map ready mask */
  Priority_Bit_map_control  block_major;  /* priority bit map block mask */
  Priority_Bit_map_control  block_minor;  /* priority bit map block mask */
}   Priority_Information;

/*
 *  The following data items are the priority bit map.
 *  Each of the sixteen bits used in the _Priority_Major_bit_map is
 *  associated with one of the sixteen entries in the _Priority_Bit_map.
 *  Each bit in the _Priority_Bit_map indicates whether or not there are
 *  threads ready at a particular priority.  The mapping of
 *  individual priority levels to particular bits is processor
 *  dependent as is the value of each bit used to indicate that
 *  threads are ready at that priority.
 */

EXTERN volatile Priority_Bit_map_control _Priority_Major_bit_map;
EXTERN Priority_Bit_map_control _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;

/*
 *  The definition of the Priority_Bit_map_control type is CPU dependent.
 *
 */

/*
 *  _Priority_Handler_initialization
 *
 *  DESCRIPTION:
 *
 *  This routine performs the initialization necessary for this handler.
 */

STATIC INLINE void _Priority_Handler_initialization( void );

/*
 *  _Priority_Is_valid
 *
 *  DESCRIPTION:
 *
 *  This function returns TRUE if the_priority if valid for a
 *  user task, and FALSE otherwise.
 */

STATIC INLINE boolean _Priority_Is_valid (
  Priority_Control the_priority
);

/*
 *  _Priority_Major
 *
 *  DESCRIPTION:
 *
 *  This function returns the major portion of the_priority.
 */

STATIC INLINE unsigned32 _Priority_Major (
  Priority_Control the_priority
);

/*
 *  _Priority_Minor
 *
 *  DESCRIPTION:
 *
 *  This function returns the minor portion of the_priority.
 */

STATIC INLINE unsigned32 _Priority_Minor (
  Priority_Control the_priority
);

/*
 *  _Priority_Add_to_bit_map
 *
 *  DESCRIPTION:
 *
 *  This routine uses the_priority_map to update the priority
 *  bit maps to indicate that a thread has been readied.
 */

STATIC INLINE void _Priority_Add_to_bit_map (
  Priority_Information *the_priority_map
);

/*
 *  _Priority_Remove_from_bit_map
 *
 *  DESCRIPTION:
 *
 *  This routine uses the_priority_map to update the priority
 *  bit maps to indicate that a thread has been removed from the
 *  ready state.
 */

STATIC INLINE void _Priority_Remove_from_bit_map (
  Priority_Information *the_priority_map
);

/*
 *  _Priority_Get_highest
 *
 *  DESCRIPTION:
 *
 *  This function returns the priority of the highest priority
 *  ready thread.
 */

STATIC INLINE Priority_Control _Priority_Get_highest( void );

/*
 *  _Priority_Initialize_information
 *
 *  DESCRIPTION:
 *
 *  This routine initializes the_priority_map so that it
 *  contains the information necessary to manage a thread
 *  at new_priority.
 */

STATIC INLINE void _Priority_Initialize_information(
  Priority_Information *the_priority_map,
  Priority_Control      new_priority
);

/*
 *  _Priority_Is_group_empty
 *
 *  DESCRIPTION:
 *
 *  This function returns TRUE if the priority GROUP is empty, and
 *  FALSE otherwise.
 */

STATIC INLINE boolean _Priority_Is_group_empty (
  Priority_Control      the_priority
);

#include <rtems/core/priority.inl>

#ifdef __cplusplus
}
#endif

#endif
/* end of include file */