xref: /onnv-gate/usr/src/uts/common/sys/task.h (revision 4584:9827aa28be49)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53684Srd117015  * Common Development and Distribution License (the "License").
63684Srd117015  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
223684Srd117015  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_TASK_H
270Sstevel@tonic-gate #define	_SYS_TASK_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/param.h>
360Sstevel@tonic-gate #include <sys/types.h>
370Sstevel@tonic-gate #include <sys/rctl.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	TASK_NORMAL	0x0	/* task may create tasks via settaskid() */
400Sstevel@tonic-gate #define	TASK_FINAL	0x1	/* task finalized, settaskid() will fail */
413684Srd117015 #define	TASK_MASK	0x1	/* task flags mask */
423684Srd117015 
433684Srd117015 #define	TASK_PROJ_PURGE	0x100000	/* purge project.* rctl entities */
443684Srd117015 #define	TASK_PROJ_MASK	0x100000
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #ifdef _KERNEL
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #include <sys/id_space.h>
490Sstevel@tonic-gate #include <sys/exacct_impl.h>
500Sstevel@tonic-gate #include <sys/kmem.h>
510Sstevel@tonic-gate 
520Sstevel@tonic-gate struct proc;
530Sstevel@tonic-gate struct zone;
540Sstevel@tonic-gate 
550Sstevel@tonic-gate typedef struct task {
560Sstevel@tonic-gate 	taskid_t	tk_tkid;	/* task id			*/
570Sstevel@tonic-gate 	uint_t		tk_flags;	/* task properties		*/
580Sstevel@tonic-gate 	struct kproject	*tk_proj;	/* project membership		*/
590Sstevel@tonic-gate 	uint_t		tk_hold_count;	/* number of members/observers	*/
600Sstevel@tonic-gate 	struct proc	*tk_memb_list;	/* pointer to the first process */
610Sstevel@tonic-gate 					/* in a doubly linked list of	*/
620Sstevel@tonic-gate 					/* task members			*/
630Sstevel@tonic-gate 	kmutex_t	tk_usage_lock;	/* lock to protect tk_*usage	*/
640Sstevel@tonic-gate 	task_usage_t	*tk_usage;	/* total task resource usage	*/
650Sstevel@tonic-gate 	task_usage_t	*tk_prevusage;	/* previous interval usage	*/
660Sstevel@tonic-gate 	task_usage_t	*tk_zoneusage;	/* previous interval usage in zone */
670Sstevel@tonic-gate 	rctl_set_t	*tk_rctls;	/* task's resource controls	*/
680Sstevel@tonic-gate 	rctl_qty_t	tk_nlwps;	/* protected by			*/
690Sstevel@tonic-gate 					/* tk_zone->zone_nlwps_lock	*/
700Sstevel@tonic-gate 	rctl_qty_t	tk_nlwps_ctl;	/* protected by tk_rctls->rcs_lock */
710Sstevel@tonic-gate 	rctl_qty_t	tk_cpu_time;	/* accumulated CPU seconds	*/
720Sstevel@tonic-gate 	struct zone	*tk_zone;	/* zone task belongs to		*/
73*4584Srh87107 	task_usage_t	*tk_inherited;	/* task resource usage		*/
74*4584Srh87107 					/* inherited with the first	*/
75*4584Srh87107 					/* member process		*/
760Sstevel@tonic-gate } task_t;
770Sstevel@tonic-gate 
780Sstevel@tonic-gate extern task_t *task0p;
790Sstevel@tonic-gate extern rctl_hndl_t rc_task_lwps;
800Sstevel@tonic-gate extern rctl_hndl_t rc_task_cpu_time;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate extern void task_init(void);
830Sstevel@tonic-gate extern task_t *task_create(projid_t, struct zone *);
840Sstevel@tonic-gate extern void task_begin(task_t *, struct proc *);
850Sstevel@tonic-gate extern void task_attach(task_t *, struct proc *);
860Sstevel@tonic-gate extern void task_change(task_t *, struct proc *);
870Sstevel@tonic-gate extern void task_detach(struct proc *);
880Sstevel@tonic-gate extern task_t *task_join(task_t *, uint_t);
890Sstevel@tonic-gate extern task_t *task_hold_by_id(taskid_t);
900Sstevel@tonic-gate extern task_t *task_hold_by_id_zone(taskid_t, zoneid_t);
910Sstevel@tonic-gate extern void task_rele(task_t *);
920Sstevel@tonic-gate extern void task_hold(task_t *);
930Sstevel@tonic-gate extern void task_end(task_t *);
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #else /* _KERNEL */
960Sstevel@tonic-gate 
970Sstevel@tonic-gate struct task;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate extern taskid_t settaskid(projid_t, uint_t);
1000Sstevel@tonic-gate extern taskid_t gettaskid(void);
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate #endif /* _KERNEL */
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate #ifdef	__cplusplus
1050Sstevel@tonic-gate }
1060Sstevel@tonic-gate #endif
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate #endif	/* _SYS_TASK_H */
109