xref: /illumos-gate/usr/src/uts/common/sys/procset.h (revision b4203d75)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*b4203d75SMarcel Telka /*	  All Rights Reserved	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifndef _SYS_PROCSET_H
327c478bd9Sstevel@tonic-gate #define	_SYS_PROCSET_H
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
397c478bd9Sstevel@tonic-gate #include <sys/types.h>
407c478bd9Sstevel@tonic-gate #include <sys/signal.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  *	This file defines the data needed to specify a set of
447c478bd9Sstevel@tonic-gate  *	processes.  These types are used by the sigsend, sigsendset,
457c478bd9Sstevel@tonic-gate  *	priocntl, priocntlset, waitid, evexit, and evexitset system
467c478bd9Sstevel@tonic-gate  *	calls.
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate #define	P_INITPID	1
497c478bd9Sstevel@tonic-gate #define	P_INITUID	0
507c478bd9Sstevel@tonic-gate #define	P_INITPGID	0
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  *	The following defines the values for an identifier type.  It
557c478bd9Sstevel@tonic-gate  *	specifies the interpretation of an id value.  An idtype and
567c478bd9Sstevel@tonic-gate  *	id together define a simple set of processes.
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate typedef enum
597c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
607c478bd9Sstevel@tonic-gate 	idtype		/* pollutes XPG4.2 namespace */
617c478bd9Sstevel@tonic-gate #endif
627c478bd9Sstevel@tonic-gate 		{
637c478bd9Sstevel@tonic-gate 	P_PID,		/* A process identifier.		*/
647c478bd9Sstevel@tonic-gate 	P_PPID,		/* A parent process identifier.		*/
657c478bd9Sstevel@tonic-gate 	P_PGID,		/* A process group (job control group)	*/
667c478bd9Sstevel@tonic-gate 			/* identifier.				*/
677c478bd9Sstevel@tonic-gate 	P_SID,		/* A session identifier.		*/
687c478bd9Sstevel@tonic-gate 	P_CID,		/* A scheduling class identifier.	*/
697c478bd9Sstevel@tonic-gate 	P_UID,		/* A user identifier.			*/
707c478bd9Sstevel@tonic-gate 	P_GID,		/* A group identifier.			*/
717c478bd9Sstevel@tonic-gate 	P_ALL,		/* All processes.			*/
727c478bd9Sstevel@tonic-gate 	P_LWPID,	/* An LWP identifier.			*/
737c478bd9Sstevel@tonic-gate 	P_TASKID,	/* A task identifier.			*/
747c478bd9Sstevel@tonic-gate 	P_PROJID,	/* A project identifier.		*/
757c478bd9Sstevel@tonic-gate 	P_POOLID,	/* A pool identifier.			*/
767c478bd9Sstevel@tonic-gate 	P_ZONEID,	/* A zone identifier.			*/
777c478bd9Sstevel@tonic-gate 	P_CTID,		/* A (process) contract identifier.	*/
787c478bd9Sstevel@tonic-gate 	P_CPUID,	/* CPU identifier.			*/
797c478bd9Sstevel@tonic-gate 	P_PSETID	/* Processor set identifier		*/
807c478bd9Sstevel@tonic-gate } idtype_t;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  *	The following defines the operations which can be performed to
857c478bd9Sstevel@tonic-gate  *	combine two simple sets of processes to form another set of
867c478bd9Sstevel@tonic-gate  *	processes.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
897c478bd9Sstevel@tonic-gate typedef enum idop {
907c478bd9Sstevel@tonic-gate 	POP_DIFF,	/* Set difference.  The processes which	*/
917c478bd9Sstevel@tonic-gate 			/* are in the left operand set and not	*/
927c478bd9Sstevel@tonic-gate 			/* in the right operand set.		*/
937c478bd9Sstevel@tonic-gate 	POP_AND,	/* Set disjunction.  The processes	*/
947c478bd9Sstevel@tonic-gate 			/* which are in both the left and right	*/
957c478bd9Sstevel@tonic-gate 			/* operand sets.			*/
967c478bd9Sstevel@tonic-gate 	POP_OR,		/* Set conjunction.  The processes	*/
977c478bd9Sstevel@tonic-gate 			/* which are in either the left or the	*/
987c478bd9Sstevel@tonic-gate 			/* right operand sets (or both).	*/
997c478bd9Sstevel@tonic-gate 	POP_XOR		/* Set exclusive or.  The processes 	*/
1007c478bd9Sstevel@tonic-gate 			/* which are in either the left or	*/
1017c478bd9Sstevel@tonic-gate 			/* right operand sets but not in both.	*/
1027c478bd9Sstevel@tonic-gate } idop_t;
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  *	The following structure is used to define a set of processes.
1077c478bd9Sstevel@tonic-gate  *	The set is defined in terms of two simple sets of processes
1087c478bd9Sstevel@tonic-gate  *	and an operator which operates on these two operand sets.
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate typedef struct procset {
1117c478bd9Sstevel@tonic-gate 	idop_t		p_op;	/* The operator connection the	*/
1127c478bd9Sstevel@tonic-gate 				/* following two operands each	*/
1137c478bd9Sstevel@tonic-gate 				/* of which is a simple set of	*/
1147c478bd9Sstevel@tonic-gate 				/* processes.			*/
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate 	idtype_t	p_lidtype;
1177c478bd9Sstevel@tonic-gate 				/* The type of the left operand	*/
1187c478bd9Sstevel@tonic-gate 				/* simple set.			*/
1197c478bd9Sstevel@tonic-gate 	id_t		p_lid;	/* The id of the left operand.	*/
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	idtype_t	p_ridtype;
1227c478bd9Sstevel@tonic-gate 				/* The type of the right	*/
1237c478bd9Sstevel@tonic-gate 				/* operand simple set.		*/
1247c478bd9Sstevel@tonic-gate 	id_t		p_rid;	/* The id of the right operand.	*/
1257c478bd9Sstevel@tonic-gate } procset_t;
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  *	The following macro can be used to initialize a procset_t
1297c478bd9Sstevel@tonic-gate  *	structure.
1307c478bd9Sstevel@tonic-gate  */
1317c478bd9Sstevel@tonic-gate #define	setprocset(psp, op, ltype, lid, rtype, rid) \
1327c478bd9Sstevel@tonic-gate 			(psp)->p_op		= (op); \
1337c478bd9Sstevel@tonic-gate 			(psp)->p_lidtype	= (ltype); \
1347c478bd9Sstevel@tonic-gate 			(psp)->p_lid		= (lid); \
1357c478bd9Sstevel@tonic-gate 			(psp)->p_ridtype	= (rtype); \
1367c478bd9Sstevel@tonic-gate 			(psp)->p_rid		= (rid);
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate #ifdef _KERNEL
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate struct proc;
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate extern int dotoprocs(procset_t *, int (*)(), char *);
1457c478bd9Sstevel@tonic-gate extern int dotolwp(procset_t *, int (*)(), char *);
1467c478bd9Sstevel@tonic-gate extern int procinset(struct proc *, procset_t *);
1477c478bd9Sstevel@tonic-gate extern int sigsendproc(struct proc *, sigsend_t *);
1487c478bd9Sstevel@tonic-gate extern int sigsendset(procset_t *, sigsend_t *);
1497c478bd9Sstevel@tonic-gate extern boolean_t cur_inset_only(procset_t *);
1507c478bd9Sstevel@tonic-gate extern id_t getmyid(idtype_t);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1557c478bd9Sstevel@tonic-gate }
1567c478bd9Sstevel@tonic-gate #endif
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #endif	/* _SYS_PROCSET_H */
159