resourcevar.h revision 1817
1129473Spjd/*
2142727Spjd * Copyright (c) 1991, 1993
3129473Spjd *	The Regents of the University of California.  All rights reserved.
4129473Spjd *
5129473Spjd * Redistribution and use in source and binary forms, with or without
6129473Spjd * modification, are permitted provided that the following conditions
7129473Spjd * are met:
8129473Spjd * 1. Redistributions of source code must retain the above copyright
9129473Spjd *    notice, this list of conditions and the following disclaimer.
10129473Spjd * 2. Redistributions in binary form must reproduce the above copyright
11129473Spjd *    notice, this list of conditions and the following disclaimer in the
12129473Spjd *    documentation and/or other materials provided with the distribution.
13155174Spjd * 3. All advertising materials mentioning features or use of this software
14129473Spjd *    must display the following acknowledgement:
15129473Spjd *	This product includes software developed by the University of
16129473Spjd *	California, Berkeley and its contributors.
17129473Spjd * 4. Neither the name of the University nor the names of its contributors
18129473Spjd *    may be used to endorse or promote products derived from this software
19129473Spjd *    without specific prior written permission.
20129473Spjd *
21129473Spjd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22129473Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23129473Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24129473Spjd * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25129473Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26129473Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27129473Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28129473Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29129473Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30129473Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31129473Spjd * SUCH DAMAGE.
32129473Spjd *
33129473Spjd *	@(#)resourcevar.h	8.3 (Berkeley) 2/22/94
34129473Spjd * $Id$
35129473Spjd */
36129473Spjd
37129473Spjd#ifndef	_SYS_RESOURCEVAR_H_
38129473Spjd#define	_SYS_RESOURCEVAR_H_
39131878Spjd
40129473Spjd/*
41129473Spjd * Kernel per-process accounting / statistics
42129473Spjd * (not necessarily resident except when running).
43129473Spjd */
44151897Srwatsonstruct pstats {
45129473Spjd#define	pstat_startzero	p_ru
46131878Spjd	struct	rusage p_ru;		/* stats for this proc */
47129473Spjd	struct	rusage p_cru;		/* sum of stats for reaped children */
48129473Spjd#define	pstat_endzero	pstat_startcopy
49129473Spjd
50129473Spjd#define	pstat_startcopy	p_timer
51129473Spjd	struct	itimerval p_timer[3];	/* virtual-time timers */
52129473Spjd
53129473Spjd	struct uprof {			/* profile arguments */
54129473Spjd		caddr_t	pr_base;	/* buffer base */
55131878Spjd		u_long	pr_size;	/* buffer size */
56131878Spjd		u_long	pr_off;		/* pc offset */
57129473Spjd		u_long	pr_scale;	/* pc scaling */
58129473Spjd		u_long	pr_addr;	/* temp storage for addr until AST */
59129473Spjd		u_long	pr_ticks;	/* temp storage for ticks until AST */
60133318Sphk	} p_prof;
61129473Spjd#define	pstat_endcopy	p_start
62129473Spjd	struct	timeval p_start;	/* starting time */
63131878Spjd};
64131878Spjd
65131878Spjd/*
66129473Spjd * Kernel shareable process resource limits.  Because this structure
67129473Spjd * is moderately large but changes infrequently, it is normally
68131878Spjd * shared copy-on-write after forks.  If a group of processes
69131878Spjd * ("threads") share modifications, the PL_SHAREMOD flag is set,
70131878Spjd * and a copy must be made for the child of a new fork that isn't
71134528Spjd * sharing modifications to the limits.
72131878Spjd */
73131878Spjdstruct plimit {
74138623Spjd	struct	rlimit pl_rlimit[RLIM_NLIMITS];
75131878Spjd#define	PL_SHAREMOD	0x01		/* modifications are shared */
76131878Spjd	int	p_lflags;
77131878Spjd	int	p_refcnt;		/* number of references */
78131878Spjd};
79131878Spjd
80129473Spjd/* add user profiling from AST */
81131878Spjd#define	ADDUPROF(p)							\
82170289Sdwmalone	addupc_task(p,							\
83131878Spjd	    (p)->p_stats->p_prof.pr_addr, (p)->p_stats->p_prof.pr_ticks)
84131878Spjd
85131878Spjd#ifdef KERNEL
86131878Spjdvoid	 addupc_intr __P((struct proc *p, u_long pc, u_int ticks));
87131878Spjdvoid	 addupc_task __P((struct proc *p, u_long pc, u_int ticks));
88132095Spjdstruct plimit
89196837Smav	*limcopy __P((struct plimit *lim));
90131878Spjd#endif
91131878Spjd#endif	/* !_SYS_RESOURCEVAR_H_ */
92132095Spjd