resourcevar.h revision 55205
11590Srgrimes/*
21590Srgrimes * Copyright (c) 1991, 1993
31590Srgrimes *	The Regents of the University of California.  All rights reserved.
41590Srgrimes *
51590Srgrimes * Redistribution and use in source and binary forms, with or without
61590Srgrimes * modification, are permitted provided that the following conditions
71590Srgrimes * are met:
81590Srgrimes * 1. Redistributions of source code must retain the above copyright
91590Srgrimes *    notice, this list of conditions and the following disclaimer.
101590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111590Srgrimes *    notice, this list of conditions and the following disclaimer in the
121590Srgrimes *    documentation and/or other materials provided with the distribution.
131590Srgrimes * 3. All advertising materials mentioning features or use of this software
141590Srgrimes *    must display the following acknowledgement:
151590Srgrimes *	This product includes software developed by the University of
161590Srgrimes *	California, Berkeley and its contributors.
171590Srgrimes * 4. Neither the name of the University nor the names of its contributors
181590Srgrimes *    may be used to endorse or promote products derived from this software
191590Srgrimes *    without specific prior written permission.
201590Srgrimes *
211590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3087697Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3187697Smarkm * SUCH DAMAGE.
3287697Smarkm *
3387697Smarkm *	@(#)resourcevar.h	8.4 (Berkeley) 1/9/95
341590Srgrimes * $FreeBSD: head/sys/sys/resourcevar.h 55205 1999-12-29 04:46:21Z peter $
3528456Scharnier */
361590Srgrimes
371590Srgrimes#ifndef	_SYS_RESOURCEVAR_H_
3887697Smarkm#define	_SYS_RESOURCEVAR_H_
391590Srgrimes
401590Srgrimes#include <sys/resource.h>
4187697Smarkm
4228456Scharnier/*
431590Srgrimes * Kernel per-process accounting / statistics
441590Srgrimes * (not necessarily resident except when running).
451590Srgrimes */
461590Srgrimesstruct pstats {
4798251Stjr#define	pstat_startzero	p_ru
4828456Scharnier	struct	rusage p_ru;		/* stats for this proc */
4995304Stjr	struct	rusage p_cru;		/* sum of stats for reaped children */
5098251Stjr	u_int64_t p_uu;			/* previous user time (us) */
511590Srgrimes	u_int64_t p_su;			/* previous system time (us) */
5278717Sdd	u_int64_t p_iu;			/* previous interrupt time (us) */
53200462Sdelphij#define	pstat_endzero	pstat_startcopy
5495304Stjr
55131054Stjr#define	pstat_startcopy	p_timer
56200462Sdelphij	struct	itimerval p_timer[3];	/* virtual-time timers */
571590Srgrimes
58227192Sed	struct uprof {			/* profile arguments */
59227192Sed		caddr_t	pr_base;	/* buffer base */
60227192Sed		u_long	pr_size;	/* buffer size */
611590Srgrimes		u_long	pr_off;		/* pc offset */
6295304Stjr		u_long	pr_scale;	/* pc scaling */
6392922Simp		u_long	pr_addr;	/* temp storage for addr until AST */
64131054Stjr		u_long	pr_ticks;	/* temp storage for ticks until AST */
6528456Scharnier	} p_prof;
6628789Scharnier#define	pstat_endcopy	p_start
67102944Sdwmalone	struct	timeval p_start;	/* starting time */
681590Srgrimes};
6995474Stjr
7095474Stjr/*
711590Srgrimes * Kernel shareable process resource limits.  Because this structure
7298251Stjr * is moderately large but changes infrequently, it is normally
7398251Stjr * shared copy-on-write after forks.  If a group of processes
7495304Stjr * ("threads") share modifications, the PL_SHAREMOD flag is set,
7595304Stjr * and a copy must be made for the child of a new fork that isn't
7695304Stjr * sharing modifications to the limits.
7795304Stjr */
7895304Stjrstruct plimit {
7995304Stjr	struct	rlimit pl_rlimit[RLIM_NLIMITS];
8095304Stjr#define	PL_SHAREMOD	0x01		/* modifications are shared */
8195304Stjr	int	p_lflags;
8295304Stjr	int	p_refcnt;		/* number of references */
8395304Stjr	rlim_t	p_cpulimit;		/* current cpu limit in usec */
8495304Stjr};
8595304Stjr
8628456Scharnier#ifdef _KERNEL
8795304Stjrstruct proc;
8895304Stjr
891590Srgrimesvoid	 addupc_intr __P((struct proc *p, u_long pc, u_int ticks));
9095304Stjrvoid	 addupc_task __P((struct proc *p, u_long pc, u_int ticks));
9195304Stjrvoid	 calcru __P((struct proc *p, struct timeval *up, struct timeval *sp,
9295304Stjr	    struct timeval *ip));
9395474Stjrint	 fuswintr __P((void *base));
9495474Stjrstruct plimit
95131054Stjr	*limcopy __P((struct plimit *lim));
9695474Stjrvoid	 ruadd __P((struct rusage *ru, struct rusage *ru2));
9795474Stjrint	 suswintr __P((void *base, int word));
9895474Stjr#endif
9995474Stjr
100131054Stjr#endif	/* !_SYS_RESOURCEVAR_H_ */
10195474Stjr