xref: /original-bsd/sys/sys/resourcevar.h (revision 27393bdf)
1 /*
2  * Copyright (c) 1991, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)resourcevar.h	8.4 (Berkeley) 01/09/95
8  */
9 
10 #ifndef	_SYS_RESOURCEVAR_H_
11 #define	_SYS_RESOURCEVAR_H_
12 
13 /*
14  * Kernel per-process accounting / statistics
15  * (not necessarily resident except when running).
16  */
17 struct pstats {
18 #define	pstat_startzero	p_ru
19 	struct	rusage p_ru;		/* stats for this proc */
20 	struct	rusage p_cru;		/* sum of stats for reaped children */
21 #define	pstat_endzero	pstat_startcopy
22 
23 #define	pstat_startcopy	p_timer
24 	struct	itimerval p_timer[3];	/* virtual-time timers */
25 
26 	struct uprof {			/* profile arguments */
27 		caddr_t	pr_base;	/* buffer base */
28 		u_long	pr_size;	/* buffer size */
29 		u_long	pr_off;		/* pc offset */
30 		u_long	pr_scale;	/* pc scaling */
31 		u_long	pr_addr;	/* temp storage for addr until AST */
32 		u_long	pr_ticks;	/* temp storage for ticks until AST */
33 	} p_prof;
34 #define	pstat_endcopy	p_start
35 	struct	timeval p_start;	/* starting time */
36 };
37 
38 /*
39  * Kernel shareable process resource limits.  Because this structure
40  * is moderately large but changes infrequently, it is normally
41  * shared copy-on-write after forks.  If a group of processes
42  * ("threads") share modifications, the PL_SHAREMOD flag is set,
43  * and a copy must be made for the child of a new fork that isn't
44  * sharing modifications to the limits.
45  */
46 struct plimit {
47 	struct	rlimit pl_rlimit[RLIM_NLIMITS];
48 #define	PL_SHAREMOD	0x01		/* modifications are shared */
49 	int	p_lflags;
50 	int	p_refcnt;		/* number of references */
51 };
52 
53 /* add user profiling from AST */
54 #define	ADDUPROF(p)							\
55 	addupc_task(p,							\
56 	    (p)->p_stats->p_prof.pr_addr, (p)->p_stats->p_prof.pr_ticks)
57 
58 #ifdef KERNEL
59 void	 addupc_intr __P((struct proc *p, u_long pc, u_int ticks));
60 void	 addupc_task __P((struct proc *p, u_long pc, u_int ticks));
61 void	 calcru __P((struct proc *p, struct timeval *up, struct timeval *sp,
62 	    struct timeval *ip));
63 struct plimit
64 	*limcopy __P((struct plimit *lim));
65 void	 ruadd __P((struct rusage *ru, struct rusage *ru2));
66 #endif
67 #endif	/* !_SYS_RESOURCEVAR_H_ */
68