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