xref: /titanic_44/usr/src/uts/common/sys/sobject.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SOBJECT_H
28 #define	_SYS_SOBJECT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/thread.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Type-number definitions for the various synchronization
41  * objects defined for the system. The numeric values
42  * assigned to the various definitions begin with zero, since
43  * the synch-object mapping array depends on these values.
44  */
45 #define	SOBJ_NONE	0	/* undefined synchonization object */
46 #define	SOBJ_MUTEX	1	/* mutex synchonization object */
47 #define	SOBJ_RWLOCK	2	/* readers/writer synchonization object */
48 #define	SOBJ_CV		3	/* cond. variable synchonization object */
49 #define	SOBJ_SEMA	4	/* semaphore synchonization object */
50 #define	SOBJ_USER	5	/* user-level synchronization object */
51 #define	SOBJ_USER_PI	6	/* user-level sobj having Prio Inheritance */
52 #define	SOBJ_SHUTTLE 	7	/* shuttle synchronization object */
53 
54 /*
55  * The following data structure is used to map
56  * synchronization object type numbers to the
57  * synchronization object's sleep queue number
58  * or the synch. object's owner function.
59  */
60 typedef struct _sobj_ops {
61 	int		sobj_type;
62 	kthread_t	*(*sobj_owner)();
63 	void		(*sobj_unsleep)(kthread_t *);
64 	void		(*sobj_change_pri)(kthread_t *, pri_t, pri_t *);
65 } sobj_ops_t;
66 
67 #ifdef	_KERNEL
68 
69 #define	SOBJ_TYPE(sobj_ops)		sobj_ops->sobj_type
70 #define	SOBJ_OWNER(sobj_ops, sobj)	(*(sobj_ops->sobj_owner))(sobj)
71 #define	SOBJ_UNSLEEP(sobj_ops, t)	(*(sobj_ops->sobj_unsleep))(t)
72 #define	SOBJ_CHANGE_PRI(sobj_ops, t, pri)	\
73 			(*(sobj_ops->sobj_change_pri))(t, pri, &t->t_pri)
74 #define	SOBJ_CHANGE_EPRI(sobj_ops, t, pri)	\
75 			(*(sobj_ops->sobj_change_pri))(t, pri, &t->t_epri)
76 
77 #endif	/* _KERNEL */
78 
79 #ifdef	__cplusplus
80 }
81 #endif
82 
83 #endif	/* _SYS_SOBJECT_H */
84