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 cma_attr_get_priority
47 * cma_t_attr *_att_ - Attribute object to get from
48 * cma_t_priority *_setting_ - Current setting
66 #define cma__int_attr_get_priority(_att_,_setting_) { \
67 cma__t_int_attr *_int_att_; \
68 (_int_att_) = cma__validate_default_attr (_att_); \
69 cma__int_lock ((_int_att_)->mutex); \
70 (*(_setting_)) = (_int_att_)->priority; \
71 cma__int_unlock ((_int_att_)->mutex); \
76 * FUNCTIONAL DESCRIPTION:
78 * cma__int_attr_get_sched - Performs work of cma_attr_get_sched
82 * cma_t_attr *_att_ _ Attributes object used
83 * cma_t_sched_policy *_setting_ - Current setting
101 #define cma__int_attr_get_sched(_att_,_setting_) { \
102 cma__t_int_attr *_int_att_; \
103 (_int_att_) = cma__validate_default_attr (_att_); \
104 cma__int_lock ((_int_att_)->mutex); \
105 (*(_setting_)) = (_int_att_)->policy; \
106 cma__int_unlock ((_int_att_)->mutex); \
111 * FUNCTIONAL DESCRIPTION:
113 * cma__int_attr_get_inherit_sched - Performs work of
114 * cma_attr_get_inherit_sched
118 * cma_t_attr *_att_ - Attributes object to use
119 * cma_t_sched_inherit *_setting_ - Current setting
127 * Inheritable scheduling policy
137 #define cma__int_attr_get_inherit_sched(_att_,_setting_) { \
138 cma__t_int_attr *_int_att_; \
139 (_int_att_) = cma__validate_default_attr (_att_); \
140 cma__int_lock ((_int_att_)->mutex); \
142 = ((_int_att_)->inherit_sched ? cma_c_sched_inherit : cma_c_sched_use_default); \
143 cma__int_unlock ((_int_att_)->mutex); \
147 * FUNCTIONAL DESCRIPTION:
149 * cma__int_attr_set_stacksize - Performs work for cma_attr_set_stacksize
153 * cma_t_attr *_att_ - Attributes object to use
154 * cma_t_natural _setting_ - Setting
170 * Change attribute objects stack size setting
172 #define cma__int_attr_set_stacksize(_att_,_setting_) { \
173 cma__t_int_attr *_int_att_; \
174 if ((_setting_) <= 0) \
175 cma__error (cma_s_badparam); \
176 _int_att_ = cma__validate_attr (_att_); \
177 cma__int_lock ((_int_att_)->mutex); \
178 _int_att_->stack_size = cma__roundup_chunksize(_setting_); \
179 cma__free_cache (_int_att_, cma__c_obj_tcb); \
180 _int_att_->cache[cma__c_obj_tcb].revision++; \
181 _int_att_->cache[cma__c_obj_stack].revision++; \
182 cma__int_unlock (_int_att_->mutex); \
186 * FUNCTIONAL DESCRIPTION:
188 * cma__int_attr_get_stacksize - Performs work of cma_attr_get_stacksize
192 * cma_t_attr *_att_ - Attributes object to use
193 * cma_t_natural *_setting_ - Current setting
201 * Attribute objects stack size setting
211 #define cma__int_attr_get_stacksize(_att_,_setting_) { \
212 cma__t_int_attr *_int_att_; \
213 (_int_att_) = cma__validate_default_attr (_att_); \
214 cma__int_lock ((_int_att_)->mutex); \
215 (*(_setting_)) = (_int_att_)->stack_size; \
216 cma__int_unlock ((_int_att_)->mutex); \
221 * FUNCTIONAL DESCRIPTION:
223 * cma__int_attr_set_guardsize - Performs work for cma_attr_set_guardsize
227 * cma_t_attr *_att_ - Attributes object to use
228 * cma_t_natural _setting_ - Setting
244 * Change attribute objects guard size setting
246 #define cma__int_attr_set_guardsize(_att_,_setting_) { \
247 cma__t_int_attr *_int_att_; \
248 _int_att_ = cma__validate_attr (_att_); \
249 cma__int_lock ((_int_att_)->mutex); \
250 _int_att_->guard_size = cma__roundup_chunksize(_setting_); \
251 cma__free_cache (_int_att_, cma__c_obj_tcb); \
252 _int_att_->cache[cma__c_obj_tcb].revision++; \
253 _int_att_->cache[cma__c_obj_stack].revision++; \
254 cma__int_unlock (_int_att_->mutex); \
258 * FUNCTIONAL DESCRIPTION:
260 * cma__int_attr_get_guardsize - Performs work of cma_attr_get_guardsize
264 * cma_t_attr *_att_ - Attributes object to use
265 * cma_t_natural *_setting_ - Current setting
273 * Attribute objects guard size setting
283 #define cma__int_attr_get_guardsize(_att_,_setting_) { \
284 cma__t_int_attr *_int_att_; \
285 (_int_att_) = cma__validate_default_attr (_att_); \
286 cma__int_lock ((_int_att_)->mutex); \
287 (*(_setting_)) = (_int_att_)->guard_size; \
288 cma__int_unlock ((_int_att_)->mutex); \
295 struct CMA__T_INT_MUTEX; /* Avoid circular dependency */
298 typedef struct CMA__T_CACHE {
299 cma_t_natural revision; /* Revisions */
301 cma__t_queue queue; /* Cache headers */
304 typedef struct CMA__T_INT_ATTR {
305 cma__t_object header; /* Common header */
306 struct CMA__T_INT_ATTR *attributes; /* Point to controlling attr */
307 struct CMA__T_INT_MUTEX *mutex; /* Serialize access to object */
308 cma_t_priority priority; /* Priority of new thread */
309 cma_t_sched_policy policy; /* Sched policy of thread */
310 cma_t_boolean inherit_sched; /* Is scheduling inherited? */
311 cma_t_natural stack_size; /* Size of stack (bytes) */
312 cma_t_natural guard_size; /* Size of guard (bytes) */
313 cma_t_mutex_kind mutex_kind; /* Mutex kind */
314 cma__t_cache cache[cma__c_obj_num]; /* Cache information */
315 cma_t_boolean delete_pending; /* attr. obj. is deleted */
316 cma_t_natural refcnt; /* Number of objects using attr. obj */
323 extern cma__t_int_attr cma__g_def_attr;
326 * INTERNAL INTERFACES
329 extern void cma__destroy_attributes (cma__t_int_attr *);
331 extern void cma__free_attributes (cma__t_int_attr *);
333 extern void cma__free_cache (cma__t_int_attr *,cma_t_natural );
335 extern cma__t_int_attr *cma__get_attributes (cma__t_int_attr *);
337 extern void cma__init_attr (void);
339 extern void cma__reinit_attr (cma_t_integer);