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
17 * Header file for attributes object
28 #include <cma_queue.h>
30 # include <sys/param.h>
32 #if _CMA_UNIX_TYPE == _CMA__SVR4
33 #include <sys/unistd.h>
36 * CONSTANTS AND MACROS
41 * FUNCTIONAL DESCRIPTION:
43 * cma__int_attr_get_priority - Performs the work of
44 * cma_attr_get_priority
48 * cma_t_attr *_att_ - Attribute object to get from
49 * cma_t_priority *_setting_ - Current setting
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); \
77 * FUNCTIONAL DESCRIPTION:
79 * cma__int_attr_get_sched - Performs work of cma_attr_get_sched
83 * cma_t_attr *_att_ _ Attributes object used
84 * cma_t_sched_policy *_setting_ - Current setting
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); \
112 * FUNCTIONAL DESCRIPTION:
114 * cma__int_attr_get_inherit_sched - Performs work of
115 * cma_attr_get_inherit_sched
119 * cma_t_attr *_att_ - Attributes object to use
120 * cma_t_sched_inherit *_setting_ - Current setting
128 * Inheritable scheduling policy
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); \
143 = ((_int_att_)->inherit_sched \
144 ? cma_c_sched_inherit : cma_c_sched_use_default); \
145 cma__int_unlock ((_int_att_)->mutex); \
149 * FUNCTIONAL DESCRIPTION:
151 * cma__int_attr_set_stacksize - Performs work for cma_attr_set_stacksize
155 * cma_t_attr *_att_ - Attributes object to use
156 * cma_t_natural _setting_ - Setting
172 * Change attribute objects stack size setting
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); \
188 * FUNCTIONAL DESCRIPTION:
190 * cma__int_attr_get_stacksize - Performs work of cma_attr_get_stacksize
194 * cma_t_attr *_att_ - Attributes object to use
195 * cma_t_natural *_setting_ - Current setting
203 * Attribute objects stack size setting
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); \
223 * FUNCTIONAL DESCRIPTION:
225 * cma__int_attr_set_guardsize - Performs work for cma_attr_set_guardsize
229 * cma_t_attr *_att_ - Attributes object to use
230 * cma_t_natural _setting_ - Setting
246 * Change attribute objects guard size setting
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); \
260 * FUNCTIONAL DESCRIPTION:
262 * cma__int_attr_get_guardsize - Performs work of cma_attr_get_guardsize
266 * cma_t_attr *_att_ - Attributes object to use
267 * cma_t_natural *_setting_ - Current setting
275 * Attribute objects guard size setting
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); \
297 struct CMA__T_INT_MUTEX
; /* Avoid circular dependency */
300 typedef struct CMA__T_CACHE
{
301 cma_t_natural revision
; /* Revisions */
303 cma__t_queue queue
; /* Cache headers */
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 */
309 struct CMA__T_INT_MUTEX
*mutex
; /* Serialize access to
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 */
326 extern cma__t_int_attr cma__g_def_attr
;
329 * INTERNAL INTERFACES
332 extern void cma__destroy_attributes (cma__t_int_attr
*);
334 extern void cma__free_attributes (cma__t_int_attr
*);
336 extern void cma__free_cache (cma__t_int_attr
*,cma_t_natural
);
338 extern cma__t_int_attr
*cma__get_attributes (cma__t_int_attr
*);
340 extern void cma__init_attr (void);
342 extern void cma__reinit_attr (cma_t_integer
);