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