root/sys/resourcevar.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    1 /*      $OpenBSD: resourcevar.h,v 1.11 2007/03/15 10:22:30 art Exp $    */
    2 /*      $NetBSD: resourcevar.h,v 1.12 1995/11/22 23:01:53 cgd Exp $     */
    3 
    4 /*
    5  * Copyright (c) 1991, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  *      @(#)resourcevar.h       8.3 (Berkeley) 2/22/94
   33  */
   34 
   35 #ifndef _SYS_RESOURCEVAR_H_
   36 #define _SYS_RESOURCEVAR_H_
   37 
   38 #include <sys/timeout.h>
   39 
   40 /*
   41  * Kernel per-process accounting / statistics
   42  * (not necessarily resident except when running).
   43  */
   44 struct pstats {
   45 #define pstat_startzero p_ru
   46         struct  rusage p_ru;            /* stats for this proc */
   47         struct  rusage p_cru;           /* sum of stats for reaped children */
   48         struct  itimerval p_timer[3];   /* virtual-time timers */
   49 #define pstat_endzero   pstat_startcopy
   50 
   51 #define pstat_startcopy p_prof
   52         struct uprof {                  /* profile arguments */
   53                 caddr_t pr_base;        /* buffer base */
   54                 size_t  pr_size;        /* buffer size */
   55                 u_long  pr_off;         /* pc offset */
   56                 u_int   pr_scale;       /* pc scaling */
   57                 u_long  pr_addr;        /* temp storage for addr until AST */
   58                 u_long  pr_ticks;       /* temp storage for ticks until AST */
   59         } p_prof;
   60 #define pstat_endcopy   p_start
   61         struct  timeval p_start;        /* starting time */
   62         struct  timeout p_virt_to;      /* virtual itimer trampoline. */
   63         struct  timeout p_prof_to;      /* prof itimer trampoline. */
   64 };
   65 
   66 /*
   67  * Kernel shareable process resource limits.  Because this structure
   68  * is moderately large but changes infrequently, it is normally
   69  * shared copy-on-write after forks.  If a group of processes
   70  * ("threads") share modifications, the PL_SHAREMOD flag is set,
   71  * and a copy must be made for the child of a new fork that isn't
   72  * sharing modifications to the limits.
   73  */
   74 struct plimit {
   75         struct  rlimit pl_rlimit[RLIM_NLIMITS];
   76 #define PL_SHAREMOD     0x01            /* modifications are shared */
   77         int     p_lflags;
   78         int     p_refcnt;               /* number of references */
   79 };
   80 
   81 /* add user profiling from AST */
   82 #define ADDUPROF(p)                                                     \
   83 do {                                                                    \
   84         atomic_clearbits_int(&(p)->p_flag, P_OWEUPC);                   \
   85         addupc_task((p), (p)->p_stats->p_prof.pr_addr,                  \
   86             (p)->p_stats->p_prof.pr_ticks);                             \
   87         (p)->p_stats->p_prof.pr_ticks = 0;                              \
   88 } while (0)
   89 
   90 #ifdef _KERNEL
   91 void     addupc_intr(struct proc *p, u_long pc);
   92 void     addupc_task(struct proc *p, u_long pc, u_int ticks);
   93 void     calcru(struct proc *p, struct timeval *up, struct timeval *sp,
   94             struct timeval *ip);
   95 struct plimit *limcopy(struct plimit *lim);
   96 void    limfree(struct plimit *);
   97 
   98 void     ruadd(struct rusage *ru, struct rusage *ru2);
   99 
  100 void    virttimer_trampoline(void *);
  101 void    proftimer_trampoline(void *);
  102 #endif
  103 #endif  /* !_SYS_RESOURCEVAR_H_ */

/* [<][>][^][v][top][bottom][index][help] */