Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* |
2 | * (c) Copyright 1990-1996 OPEN SOFTWARE FOUNDATION, INC. | |
3 | * (c) Copyright 1990-1996 HEWLETT-PACKARD COMPANY | |
4 | * (c) Copyright 1990-1996 DIGITAL EQUIPMENT CORPORATION | |
5 | * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems | |
6 | * To anyone who acknowledges that this file is provided "AS IS" without | |
7 | * any express or implied warranty: permission to use, copy, modify, and | |
8 | * distribute this file for any purpose is hereby granted without fee, | |
9 | * provided that the above copyright notices and this notice appears in | |
10 | * all source code copies, and that none of the names listed above be used | |
11 | * in advertising or publicity pertaining to distribution of the software | |
12 | * without specific, written prior permission. None of these organizations | |
13 | * makes any representations about the suitability of this software for | |
14 | * any purpose. | |
15 | */ | |
16 | /* | |
17 | * Header file for attributes object | |
18 | */ | |
19 | ||
20 | #ifndef CMA_ATTR | |
21 | #define CMA_ATTR | |
22 | ||
23 | /* | |
24 | * INCLUDE FILES | |
25 | */ | |
26 | ||
27 | #include <cma_defs.h> | |
28 | #include <cma_queue.h> | |
29 | #ifdef __hpux | |
30 | # include <sys/param.h> | |
31 | #endif | |
32 | #if _CMA_UNIX_TYPE == _CMA__SVR4 | |
33 | #include <sys/unistd.h> | |
34 | #endif | |
35 | /* | |
36 | * CONSTANTS AND MACROS | |
37 | */ | |
38 | ||
39 | \f | |
40 | /* | |
41 | * FUNCTIONAL DESCRIPTION: | |
42 | * | |
9a2b4c1b MS |
43 | * cma__int_attr_get_priority - Performs the work of |
44 | * cma_attr_get_priority | |
c906108c SS |
45 | * |
46 | * FORMAL PARAMETERS: | |
47 | * | |
48 | * cma_t_attr *_att_ - Attribute object to get from | |
49 | * cma_t_priority *_setting_ - Current setting | |
50 | * | |
51 | * IMPLICIT INPUTS: | |
52 | * | |
53 | * none | |
54 | * | |
55 | * IMPLICIT OUTPUTS: | |
56 | * | |
57 | * priority | |
58 | * | |
59 | * FUNCTION VALUE: | |
60 | * | |
61 | * none | |
62 | * | |
63 | * SIDE EFFECTS: | |
64 | * | |
65 | * none | |
66 | */ | |
67 | #define cma__int_attr_get_priority(_att_,_setting_) { \ | |
68 | cma__t_int_attr *_int_att_; \ | |
69 | (_int_att_) = cma__validate_default_attr (_att_); \ | |
70 | cma__int_lock ((_int_att_)->mutex); \ | |
71 | (*(_setting_)) = (_int_att_)->priority; \ | |
72 | cma__int_unlock ((_int_att_)->mutex); \ | |
73 | } | |
74 | ||
75 | \f | |
76 | /* | |
77 | * FUNCTIONAL DESCRIPTION: | |
78 | * | |
79 | * cma__int_attr_get_sched - Performs work of cma_attr_get_sched | |
80 | * | |
81 | * FORMAL PARAMETERS: | |
82 | * | |
83 | * cma_t_attr *_att_ _ Attributes object used | |
84 | * cma_t_sched_policy *_setting_ - Current setting | |
85 | * | |
86 | * IMPLICIT INPUTS: | |
87 | * | |
88 | * none | |
89 | * | |
90 | * IMPLICIT OUTPUTS: | |
91 | * | |
92 | * scheduling policy | |
93 | * | |
94 | * FUNCTION VALUE: | |
95 | * | |
96 | * none | |
97 | * | |
98 | * SIDE EFFECTS: | |
99 | * | |
100 | * none | |
101 | */ | |
102 | #define cma__int_attr_get_sched(_att_,_setting_) { \ | |
103 | cma__t_int_attr *_int_att_; \ | |
104 | (_int_att_) = cma__validate_default_attr (_att_); \ | |
105 | cma__int_lock ((_int_att_)->mutex); \ | |
106 | (*(_setting_)) = (_int_att_)->policy; \ | |
107 | cma__int_unlock ((_int_att_)->mutex); \ | |
108 | } | |
109 | ||
110 | \f | |
111 | /* | |
112 | * FUNCTIONAL DESCRIPTION: | |
113 | * | |
114 | * cma__int_attr_get_inherit_sched - Performs work of | |
115 | * cma_attr_get_inherit_sched | |
116 | * | |
117 | * FORMAL PARAMETERS: | |
118 | * | |
119 | * cma_t_attr *_att_ - Attributes object to use | |
120 | * cma_t_sched_inherit *_setting_ - Current setting | |
121 | * | |
122 | * IMPLICIT INPUTS: | |
123 | * | |
124 | * none | |
125 | * | |
126 | * IMPLICIT OUTPUTS: | |
127 | * | |
128 | * Inheritable scheduling policy | |
129 | * | |
130 | * FUNCTION VALUE: | |
131 | * | |
132 | * none | |
133 | * | |
134 | * SIDE EFFECTS: | |
135 | * | |
136 | * none | |
137 | */ | |
138 | #define cma__int_attr_get_inherit_sched(_att_,_setting_) { \ | |
139 | cma__t_int_attr *_int_att_; \ | |
140 | (_int_att_) = cma__validate_default_attr (_att_); \ | |
141 | cma__int_lock ((_int_att_)->mutex); \ | |
142 | (*(_setting_)) \ | |
9a2b4c1b MS |
143 | = ((_int_att_)->inherit_sched \ |
144 | ? cma_c_sched_inherit : cma_c_sched_use_default); \ | |
c906108c SS |
145 | cma__int_unlock ((_int_att_)->mutex); \ |
146 | } | |
147 | \f | |
148 | /* | |
149 | * FUNCTIONAL DESCRIPTION: | |
150 | * | |
151 | * cma__int_attr_set_stacksize - Performs work for cma_attr_set_stacksize | |
152 | * | |
153 | * FORMAL PARAMETERS: | |
154 | * | |
155 | * cma_t_attr *_att_ - Attributes object to use | |
156 | * cma_t_natural _setting_ - Setting | |
157 | * | |
158 | * IMPLICIT INPUTS: | |
159 | * | |
160 | * none | |
161 | * | |
162 | * IMPLICIT OUTPUTS: | |
163 | * | |
164 | * none | |
165 | * | |
166 | * FUNCTION VALUE: | |
167 | * | |
168 | * none | |
169 | * | |
170 | * SIDE EFFECTS: | |
171 | * | |
172 | * Change attribute objects stack size setting | |
173 | */ | |
174 | #define cma__int_attr_set_stacksize(_att_,_setting_) { \ | |
175 | cma__t_int_attr *_int_att_; \ | |
176 | if ((_setting_) <= 0) \ | |
177 | cma__error (cma_s_badparam); \ | |
178 | _int_att_ = cma__validate_attr (_att_); \ | |
179 | cma__int_lock ((_int_att_)->mutex); \ | |
180 | _int_att_->stack_size = cma__roundup_chunksize(_setting_); \ | |
181 | cma__free_cache (_int_att_, cma__c_obj_tcb); \ | |
182 | _int_att_->cache[cma__c_obj_tcb].revision++; \ | |
183 | _int_att_->cache[cma__c_obj_stack].revision++; \ | |
184 | cma__int_unlock (_int_att_->mutex); \ | |
185 | } | |
186 | \f | |
187 | /* | |
188 | * FUNCTIONAL DESCRIPTION: | |
189 | * | |
190 | * cma__int_attr_get_stacksize - Performs work of cma_attr_get_stacksize | |
191 | * | |
192 | * FORMAL PARAMETERS: | |
193 | * | |
194 | * cma_t_attr *_att_ - Attributes object to use | |
195 | * cma_t_natural *_setting_ - Current setting | |
196 | * | |
197 | * IMPLICIT INPUTS: | |
198 | * | |
199 | * none | |
200 | * | |
201 | * IMPLICIT OUTPUTS: | |
202 | * | |
203 | * Attribute objects stack size setting | |
204 | * | |
205 | * FUNCTION VALUE: | |
206 | * | |
207 | * none | |
208 | * | |
209 | * SIDE EFFECTS: | |
210 | * | |
211 | * none | |
212 | */ | |
213 | #define cma__int_attr_get_stacksize(_att_,_setting_) { \ | |
214 | cma__t_int_attr *_int_att_; \ | |
215 | (_int_att_) = cma__validate_default_attr (_att_); \ | |
216 | cma__int_lock ((_int_att_)->mutex); \ | |
217 | (*(_setting_)) = (_int_att_)->stack_size; \ | |
218 | cma__int_unlock ((_int_att_)->mutex); \ | |
219 | } | |
220 | ||
221 | \f | |
222 | /* | |
223 | * FUNCTIONAL DESCRIPTION: | |
224 | * | |
225 | * cma__int_attr_set_guardsize - Performs work for cma_attr_set_guardsize | |
226 | * | |
227 | * FORMAL PARAMETERS: | |
228 | * | |
229 | * cma_t_attr *_att_ - Attributes object to use | |
230 | * cma_t_natural _setting_ - Setting | |
231 | * | |
232 | * IMPLICIT INPUTS: | |
233 | * | |
234 | * none | |
235 | * | |
236 | * IMPLICIT OUTPUTS: | |
237 | * | |
238 | * none | |
239 | * | |
240 | * FUNCTION VALUE: | |
241 | * | |
242 | * none | |
243 | * | |
244 | * SIDE EFFECTS: | |
245 | * | |
246 | * Change attribute objects guard size setting | |
247 | */ | |
248 | #define cma__int_attr_set_guardsize(_att_,_setting_) { \ | |
249 | cma__t_int_attr *_int_att_; \ | |
250 | _int_att_ = cma__validate_attr (_att_); \ | |
251 | cma__int_lock ((_int_att_)->mutex); \ | |
252 | _int_att_->guard_size = cma__roundup_chunksize(_setting_); \ | |
253 | cma__free_cache (_int_att_, cma__c_obj_tcb); \ | |
254 | _int_att_->cache[cma__c_obj_tcb].revision++; \ | |
255 | _int_att_->cache[cma__c_obj_stack].revision++; \ | |
256 | cma__int_unlock (_int_att_->mutex); \ | |
257 | } | |
258 | \f | |
259 | /* | |
260 | * FUNCTIONAL DESCRIPTION: | |
261 | * | |
262 | * cma__int_attr_get_guardsize - Performs work of cma_attr_get_guardsize | |
263 | * | |
264 | * FORMAL PARAMETERS: | |
265 | * | |
266 | * cma_t_attr *_att_ - Attributes object to use | |
267 | * cma_t_natural *_setting_ - Current setting | |
268 | * | |
269 | * IMPLICIT INPUTS: | |
270 | * | |
271 | * none | |
272 | * | |
273 | * IMPLICIT OUTPUTS: | |
274 | * | |
275 | * Attribute objects guard size setting | |
276 | * | |
277 | * FUNCTION VALUE: | |
278 | * | |
279 | * none | |
280 | * | |
281 | * SIDE EFFECTS: | |
282 | * | |
283 | * none | |
284 | */ | |
285 | #define cma__int_attr_get_guardsize(_att_,_setting_) { \ | |
286 | cma__t_int_attr *_int_att_; \ | |
287 | (_int_att_) = cma__validate_default_attr (_att_); \ | |
288 | cma__int_lock ((_int_att_)->mutex); \ | |
289 | (*(_setting_)) = (_int_att_)->guard_size; \ | |
290 | cma__int_unlock ((_int_att_)->mutex); \ | |
291 | } | |
292 | ||
293 | /* | |
294 | * TYPEDEFS | |
295 | */ | |
296 | #ifndef __STDC__ | |
297 | struct CMA__T_INT_MUTEX; /* Avoid circular dependency */ | |
298 | #endif | |
299 | ||
300 | typedef struct CMA__T_CACHE { | |
301 | cma_t_natural revision; /* Revisions */ | |
302 | cma_t_natural count; | |
303 | cma__t_queue queue; /* Cache headers */ | |
304 | } cma__t_cache; | |
305 | ||
306 | typedef struct CMA__T_INT_ATTR { | |
307 | cma__t_object header; /* Common header */ | |
308 | struct CMA__T_INT_ATTR *attributes; /* Point to controlling attr */ | |
9a2b4c1b MS |
309 | struct CMA__T_INT_MUTEX *mutex; /* Serialize access to |
310 | object */ | |
c906108c SS |
311 | cma_t_priority priority; /* Priority of new thread */ |
312 | cma_t_sched_policy policy; /* Sched policy of thread */ | |
313 | cma_t_boolean inherit_sched; /* Is scheduling inherited? */ | |
314 | cma_t_natural stack_size; /* Size of stack (bytes) */ | |
315 | cma_t_natural guard_size; /* Size of guard (bytes) */ | |
316 | cma_t_mutex_kind mutex_kind; /* Mutex kind */ | |
317 | cma__t_cache cache[cma__c_obj_num]; /* Cache information */ | |
318 | cma_t_boolean delete_pending; /* attr. obj. is deleted */ | |
319 | cma_t_natural refcnt; /* Number of objects using attr. obj */ | |
320 | } cma__t_int_attr; | |
321 | ||
322 | /* | |
323 | * GLOBAL DATA | |
324 | */ | |
325 | ||
326 | extern cma__t_int_attr cma__g_def_attr; | |
327 | ||
328 | /* | |
329 | * INTERNAL INTERFACES | |
330 | */ | |
331 | ||
332 | extern void cma__destroy_attributes (cma__t_int_attr *); | |
333 | ||
334 | extern void cma__free_attributes (cma__t_int_attr *); | |
335 | ||
336 | extern void cma__free_cache (cma__t_int_attr *,cma_t_natural ); | |
337 | ||
338 | extern cma__t_int_attr *cma__get_attributes (cma__t_int_attr *); | |
339 | ||
340 | extern void cma__init_attr (void); | |
341 | ||
342 | extern void cma__reinit_attr (cma_t_integer); | |
343 | ||
344 | #endif |