xref: /netbsd-src/external/cddl/osnet/dist/uts/common/sys/procset.h (revision f3f87b32db28e53a1bc0e76f58272fc09a2f1453)
1*f3f87b32Shannken /*
2*f3f87b32Shannken  * CDDL HEADER START
3*f3f87b32Shannken  *
4*f3f87b32Shannken  * The contents of this file are subject to the terms of the
5*f3f87b32Shannken  * Common Development and Distribution License, Version 1.0 only
6*f3f87b32Shannken  * (the "License").  You may not use this file except in compliance
7*f3f87b32Shannken  * with the License.
8*f3f87b32Shannken  *
9*f3f87b32Shannken  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*f3f87b32Shannken  * or http://www.opensolaris.org/os/licensing.
11*f3f87b32Shannken  * See the License for the specific language governing permissions
12*f3f87b32Shannken  * and limitations under the License.
13*f3f87b32Shannken  *
14*f3f87b32Shannken  * When distributing Covered Code, include this CDDL HEADER in each
15*f3f87b32Shannken  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*f3f87b32Shannken  * If applicable, add the following below this CDDL HEADER, with the
17*f3f87b32Shannken  * fields enclosed by brackets "[]" replaced with your own identifying
18*f3f87b32Shannken  * information: Portions Copyright [yyyy] [name of copyright owner]
19*f3f87b32Shannken  *
20*f3f87b32Shannken  * CDDL HEADER END
21*f3f87b32Shannken  */
22*f3f87b32Shannken /*
23*f3f87b32Shannken  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*f3f87b32Shannken  * Use is subject to license terms.
25*f3f87b32Shannken  */
26*f3f87b32Shannken 
27*f3f87b32Shannken /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*f3f87b32Shannken /*	  All Rights Reserved  	*/
29*f3f87b32Shannken 
30*f3f87b32Shannken 
31*f3f87b32Shannken #ifndef _SYS_PROCSET_H
32*f3f87b32Shannken #define	_SYS_PROCSET_H
33*f3f87b32Shannken 
34*f3f87b32Shannken #ifndef __NetBSD__
35*f3f87b32Shannken #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.6 */
36*f3f87b32Shannken #endif
37*f3f87b32Shannken 
38*f3f87b32Shannken #ifdef	__cplusplus
39*f3f87b32Shannken extern "C" {
40*f3f87b32Shannken #endif
41*f3f87b32Shannken 
42*f3f87b32Shannken #include <sys/feature_tests.h>
43*f3f87b32Shannken #include <sys/types.h>
44*f3f87b32Shannken #include <sys/signal.h>
45*f3f87b32Shannken 
46*f3f87b32Shannken /*
47*f3f87b32Shannken  *	This file defines the data needed to specify a set of
48*f3f87b32Shannken  *	processes.  These types are used by the sigsend, sigsendset,
49*f3f87b32Shannken  *	priocntl, priocntlset, waitid, evexit, and evexitset system
50*f3f87b32Shannken  *	calls.
51*f3f87b32Shannken  */
52*f3f87b32Shannken #define	P_INITPID	1
53*f3f87b32Shannken #define	P_INITUID	0
54*f3f87b32Shannken #define	P_INITPGID	0
55*f3f87b32Shannken 
56*f3f87b32Shannken #ifdef __NetBSD__
57*f3f87b32Shannken 
58*f3f87b32Shannken #include <sys/idtype.h>
59*f3f87b32Shannken 
60*f3f87b32Shannken #else /* __NetBSD__ */
61*f3f87b32Shannken 
62*f3f87b32Shannken #ifndef _IDTYPE_T_DECLARED
63*f3f87b32Shannken 
64*f3f87b32Shannken /*
65*f3f87b32Shannken  *	The following defines the values for an identifier type.  It
66*f3f87b32Shannken  *	specifies the interpretation of an id value.  An idtype and
67*f3f87b32Shannken  *	id together define a simple set of processes.
68*f3f87b32Shannken  */
69*f3f87b32Shannken typedef enum
70*f3f87b32Shannken #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
71*f3f87b32Shannken 	idtype		/* pollutes XPG4.2 namespace */
72*f3f87b32Shannken #endif
73*f3f87b32Shannken 		{
74*f3f87b32Shannken 	P_PID,		/* A process identifier.		*/
75*f3f87b32Shannken 	P_PPID,		/* A parent process identifier.		*/
76*f3f87b32Shannken 	P_PGID,		/* A process group (job control group)	*/
77*f3f87b32Shannken 			/* identifier.				*/
78*f3f87b32Shannken 	P_SID,		/* A session identifier.		*/
79*f3f87b32Shannken 	P_CID,		/* A scheduling class identifier.	*/
80*f3f87b32Shannken 	P_UID,		/* A user identifier.			*/
81*f3f87b32Shannken 	P_GID,		/* A group identifier.			*/
82*f3f87b32Shannken 	P_ALL,		/* All processes.			*/
83*f3f87b32Shannken 	P_LWPID,	/* An LWP identifier.			*/
84*f3f87b32Shannken 	P_TASKID,	/* A task identifier.			*/
85*f3f87b32Shannken 	P_PROJID,	/* A project identifier.		*/
86*f3f87b32Shannken 	P_POOLID,	/* A pool identifier.			*/
87*f3f87b32Shannken 	P_ZONEID,	/* A zone identifier.			*/
88*f3f87b32Shannken 	P_CTID,		/* A (process) contract identifier.	*/
89*f3f87b32Shannken 	P_CPUID,	/* CPU identifier.			*/
90*f3f87b32Shannken 	P_PSETID	/* Processor set identifier		*/
91*f3f87b32Shannken } idtype_t;
92*f3f87b32Shannken 
93*f3f87b32Shannken #define	_IDTYPE_T_DECLARED
94*f3f87b32Shannken 
95*f3f87b32Shannken #endif
96*f3f87b32Shannken 
97*f3f87b32Shannken #endif /* __NetBSD__ */
98*f3f87b32Shannken 
99*f3f87b32Shannken /*
100*f3f87b32Shannken  *	The following defines the operations which can be performed to
101*f3f87b32Shannken  *	combine two simple sets of processes to form another set of
102*f3f87b32Shannken  *	processes.
103*f3f87b32Shannken  */
104*f3f87b32Shannken #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
105*f3f87b32Shannken typedef enum idop {
106*f3f87b32Shannken 	POP_DIFF,	/* Set difference.  The processes which	*/
107*f3f87b32Shannken 			/* are in the left operand set and not	*/
108*f3f87b32Shannken 			/* in the right operand set.		*/
109*f3f87b32Shannken 	POP_AND,	/* Set disjunction.  The processes	*/
110*f3f87b32Shannken 			/* which are in both the left and right	*/
111*f3f87b32Shannken 			/* operand sets.			*/
112*f3f87b32Shannken 	POP_OR,		/* Set conjunction.  The processes	*/
113*f3f87b32Shannken 			/* which are in either the left or the	*/
114*f3f87b32Shannken 			/* right operand sets (or both).	*/
115*f3f87b32Shannken 	POP_XOR		/* Set exclusive or.  The processes 	*/
116*f3f87b32Shannken 			/* which are in either the left or	*/
117*f3f87b32Shannken 			/* right operand sets but not in both.	*/
118*f3f87b32Shannken } idop_t;
119*f3f87b32Shannken 
120*f3f87b32Shannken 
121*f3f87b32Shannken /*
122*f3f87b32Shannken  *	The following structure is used to define a set of processes.
123*f3f87b32Shannken  *	The set is defined in terms of two simple sets of processes
124*f3f87b32Shannken  *	and an operator which operates on these two operand sets.
125*f3f87b32Shannken  */
126*f3f87b32Shannken typedef struct procset {
127*f3f87b32Shannken 	idop_t		p_op;	/* The operator connection the	*/
128*f3f87b32Shannken 				/* following two operands each	*/
129*f3f87b32Shannken 				/* of which is a simple set of	*/
130*f3f87b32Shannken 				/* processes.			*/
131*f3f87b32Shannken 
132*f3f87b32Shannken 	idtype_t	p_lidtype;
133*f3f87b32Shannken 				/* The type of the left operand	*/
134*f3f87b32Shannken 				/* simple set.			*/
135*f3f87b32Shannken 	id_t		p_lid;	/* The id of the left operand.	*/
136*f3f87b32Shannken 
137*f3f87b32Shannken 	idtype_t	p_ridtype;
138*f3f87b32Shannken 				/* The type of the right	*/
139*f3f87b32Shannken 				/* operand simple set.		*/
140*f3f87b32Shannken 	id_t		p_rid;	/* The id of the right operand.	*/
141*f3f87b32Shannken } procset_t;
142*f3f87b32Shannken 
143*f3f87b32Shannken /*
144*f3f87b32Shannken  *	The following macro can be used to initialize a procset_t
145*f3f87b32Shannken  *	structure.
146*f3f87b32Shannken  */
147*f3f87b32Shannken #define	setprocset(psp, op, ltype, lid, rtype, rid) \
148*f3f87b32Shannken 			(psp)->p_op		= (op); \
149*f3f87b32Shannken 			(psp)->p_lidtype	= (ltype); \
150*f3f87b32Shannken 			(psp)->p_lid		= (lid); \
151*f3f87b32Shannken 			(psp)->p_ridtype	= (rtype); \
152*f3f87b32Shannken 			(psp)->p_rid		= (rid);
153*f3f87b32Shannken 
154*f3f87b32Shannken #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
155*f3f87b32Shannken 
156*f3f87b32Shannken #ifdef illumos
157*f3f87b32Shannken #ifdef _KERNEL
158*f3f87b32Shannken 
159*f3f87b32Shannken struct proc;
160*f3f87b32Shannken 
161*f3f87b32Shannken extern int dotoprocs(procset_t *, int (*)(), char *);
162*f3f87b32Shannken extern int dotolwp(procset_t *, int (*)(), char *);
163*f3f87b32Shannken extern int procinset(struct proc *, procset_t *);
164*f3f87b32Shannken extern int sigsendproc(struct proc *, sigsend_t *);
165*f3f87b32Shannken extern int sigsendset(procset_t *, sigsend_t *);
166*f3f87b32Shannken extern boolean_t cur_inset_only(procset_t *);
167*f3f87b32Shannken extern id_t getmyid(idtype_t);
168*f3f87b32Shannken 
169*f3f87b32Shannken #endif	/* _KERNEL */
170*f3f87b32Shannken #endif
171*f3f87b32Shannken 
172*f3f87b32Shannken #ifdef	__cplusplus
173*f3f87b32Shannken }
174*f3f87b32Shannken #endif
175*f3f87b32Shannken 
176*f3f87b32Shannken #endif	/* _SYS_PROCSET_H */
177