xref: /titanic_50/usr/src/uts/common/sys/procset.h (revision 5d0e1406420f52cc4d3d0543044034c4894b5865)
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 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 #ifndef _SYS_PROCSET_H
32 #define	_SYS_PROCSET_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.6 */
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/feature_tests.h>
41 #include <sys/types.h>
42 #include <sys/signal.h>
43 
44 /*
45  *	This file defines the data needed to specify a set of
46  *	processes.  These types are used by the sigsend, sigsendset,
47  *	priocntl, priocntlset, waitid, evexit, and evexitset system
48  *	calls.
49  */
50 #define	P_INITPID	1
51 #define	P_INITUID	0
52 #define	P_INITPGID	0
53 
54 
55 /*
56  *	The following defines the values for an identifier type.  It
57  *	specifies the interpretation of an id value.  An idtype and
58  *	id together define a simple set of processes.
59  */
60 typedef enum
61 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
62 	idtype		/* pollutes XPG4.2 namespace */
63 #endif
64 		{
65 	P_PID,		/* A process identifier.		*/
66 	P_PPID,		/* A parent process identifier.		*/
67 	P_PGID,		/* A process group (job control group)	*/
68 			/* identifier.				*/
69 	P_SID,		/* A session identifier.		*/
70 	P_CID,		/* A scheduling class identifier.	*/
71 	P_UID,		/* A user identifier.			*/
72 	P_GID,		/* A group identifier.			*/
73 	P_ALL,		/* All processes.			*/
74 	P_LWPID,	/* An LWP identifier.			*/
75 	P_TASKID,	/* A task identifier.			*/
76 	P_PROJID,	/* A project identifier.		*/
77 	P_POOLID,	/* A pool identifier.			*/
78 	P_ZONEID,	/* A zone identifier.			*/
79 	P_CTID,		/* A (process) contract identifier.	*/
80 	P_CPUID,	/* CPU identifier.			*/
81 	P_PSETID	/* Processor set identifier		*/
82 } idtype_t;
83 
84 
85 /*
86  *	The following defines the operations which can be performed to
87  *	combine two simple sets of processes to form another set of
88  *	processes.
89  */
90 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
91 typedef enum idop {
92 	POP_DIFF,	/* Set difference.  The processes which	*/
93 			/* are in the left operand set and not	*/
94 			/* in the right operand set.		*/
95 	POP_AND,	/* Set disjunction.  The processes	*/
96 			/* which are in both the left and right	*/
97 			/* operand sets.			*/
98 	POP_OR,		/* Set conjunction.  The processes	*/
99 			/* which are in either the left or the	*/
100 			/* right operand sets (or both).	*/
101 	POP_XOR		/* Set exclusive or.  The processes 	*/
102 			/* which are in either the left or	*/
103 			/* right operand sets but not in both.	*/
104 } idop_t;
105 
106 
107 /*
108  *	The following structure is used to define a set of processes.
109  *	The set is defined in terms of two simple sets of processes
110  *	and an operator which operates on these two operand sets.
111  */
112 typedef struct procset {
113 	idop_t		p_op;	/* The operator connection the	*/
114 				/* following two operands each	*/
115 				/* of which is a simple set of	*/
116 				/* processes.			*/
117 
118 	idtype_t	p_lidtype;
119 				/* The type of the left operand	*/
120 				/* simple set.			*/
121 	id_t		p_lid;	/* The id of the left operand.	*/
122 
123 	idtype_t	p_ridtype;
124 				/* The type of the right	*/
125 				/* operand simple set.		*/
126 	id_t		p_rid;	/* The id of the right operand.	*/
127 } procset_t;
128 
129 /*
130  *	The following macro can be used to initialize a procset_t
131  *	structure.
132  */
133 #define	setprocset(psp, op, ltype, lid, rtype, rid) \
134 			(psp)->p_op		= (op); \
135 			(psp)->p_lidtype	= (ltype); \
136 			(psp)->p_lid		= (lid); \
137 			(psp)->p_ridtype	= (rtype); \
138 			(psp)->p_rid		= (rid);
139 
140 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
141 
142 #ifdef _KERNEL
143 
144 struct proc;
145 
146 extern int dotoprocs(procset_t *, int (*)(), char *);
147 extern int dotolwp(procset_t *, int (*)(), char *);
148 extern int procinset(struct proc *, procset_t *);
149 extern int sigsendproc(struct proc *, sigsend_t *);
150 extern int sigsendset(procset_t *, sigsend_t *);
151 extern boolean_t cur_inset_only(procset_t *);
152 extern id_t getmyid(idtype_t);
153 
154 #endif	/* _KERNEL */
155 
156 #ifdef	__cplusplus
157 }
158 #endif
159 
160 #endif	/* _SYS_PROCSET_H */
161