/* $Header: resource.h,v 1.15.98.11 96/05/03 12:40:17 ukrishna Exp $ * $Locker: BERT $ */ #ifndef _SYS_RESOURCE_INCLUDED #define _SYS_RESOURCE_INCLUDED #ifdef _KERNEL_BUILD #include "../h/stdsyms.h" #else /* ! _KERNEL_BUILD */ #include #endif /* _KERNEL_BUILD */ #ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED #ifdef _KERNEL_BUILD #include "../h/types.h" #include "../h/time.h" #else /* ! _KERNEL_BUILD */ #include #include #endif /* _KERNEL_BUILD */ /* * Resource limits */ #if !defined(_KERNEL) # define __rlimit rlimit # include # undef __rlimit # if defined(_LARGEFILE64_SOURCE) # define __rlimit rlimit64 # define rlim_t rlim64_t # include # undef rlim_t # undef __rlimit # endif /* _LARGEFILE64_SOURCE */ #else /* _KERNEL */ # define __rlimit rlimit64 # define rlim_t rlim64_t # include "_rlimit_body.h" # undef rlim_t # undef __rlimit # define __rlimit rlimit32 # define rlim_t rlim32_t # include "_rlimit_body.h" # undef rlim_t # undef __rlimit # define __rlimit k_rlimit # define rlim_t k_rlim_t # include "_rlimit_body.h" # undef rlim_t # undef __rlimit #endif /* ! _KERNEL */ /* * Process priority specifications to get/setpriority. */ #define PRIO_MIN -20 #define PRIO_MAX 20 #define PRIO_PROCESS 0 #define PRIO_PGRP 1 #define PRIO_USER 2 /* * Resource utilization information. */ #define RUSAGE_SELF 0 #define RUSAGE_CHILDREN -1 struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ /* actual values kept in proc struct */ long ru_maxrss; #define ru_first ru_ixrss long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data " */ long ru_isrss; /* integral unshared stack " */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_ioch; /* # of characters read/written */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary " */ #define ru_last ru_nivcsw }; /* * Within the kernel, time information is stored as ticks rather than as * seconds plus microseconds. This makes normal updates more efficient * and eliminates race conditions while updating. The seconds field is * used to store ticks and the microseconds field is unused. */ /* * The information is converted to seconds plus microseconds when given * to the user via the getrusage and wait3 system calls. */ /* Function prototypes */ #ifndef _KERNEL #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #ifdef _PROTOTYPES extern int getpriority(int, id_t); extern int getrusage(int, struct rusage *); extern int setpriority(int, id_t, int); # ifndef _FILE64 extern int getrlimit(int, struct rlimit *); extern int setrlimit(int, const struct rlimit *); # else static int getrlimit(int, struct rlimit *); static int setrlimit(int, const struct rlimit *); # endif # if defined(_LARGEFILE64_SOURCE) extern int getrlimit64(int, struct rlimit64 *); extern int setrlimit64(int, const struct rlimit64 *); # endif #else /* not _PROTOTYPES */ extern int getpriority(); extern int getrusage(); extern int setpriority(); extern int getrlimit(); extern int setrlimit(); # if defined(_LARGEFILE64_SOURCE) extern int getrlimit64(); extern int setrlimit64(); # endif #endif /* not _PROTOTYPES */ #if defined(_FILE64) static getrlimit(a,b) struct rlimit *b; { return __getrlimit64(a,b); } # ifdef __STDC_EXT__ static setrlimit(a,b) const struct rlimit *b; { return __setrlimit64(a,b); } # else static setrlimit(a,b) struct rlimit *b; { return __setrlimit64(a,b); } # endif #endif #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* not _KERNEL */ /* * Resource limits */ #if defined(_KERNEL) || defined(_LARGEFILE64_SOURCE) # define RLIM64_INFINITY 0x7fffffffffffffffLL # define RLIM32_INFINITY 0x7fffffff #endif #if defined(_KERNEL) # define K_RLIM_INFINITY RLIM64_INFINITY # define ATT_BYTESPERBLOCK 512 # define LOG_ATT_BYTESPERBLOCK 9 /* bytes to 1/2k blocks and 1/2k blocks to bytes conversion macro. */ # define bt2bk(x) (((unsigned) (x)) >> (LOG_ATT_BYTESPERBLOCK)) # define bk2bt(x) (((unsigned) (x)) << (LOG_ATT_BYTESPERBLOCK)) # define ULIMIT_MAX bt2bk(0x80000000) #else # if defined(_FILE64) # define RLIM_INFINITY 0x7fffffffffffffffLL # else # define RLIM_INFINITY 0x7fffffff # endif /* _FILE64 */ #endif /* _KERNEL */ #define RLIMIT_CPU 0 /* cpu time in milliseconds */ #define RLIMIT_DATA 2 /* data size */ #define RLIMIT_STACK 3 /* stack size */ #define RLIMIT_RSS 5 /* resident set size */ #define RLIMIT_FSIZE 1 /* maximum file size */ #define RLIMIT_CORE 4 /* core file size */ #define RLIMIT_NOFILE 6 /* maximum number of open files */ #define RLIMIT_OPEN_MAX RLIMIT_NOFILE /* maximum number of open files */ #define RLIMIT_AS 7 /* maximum number of open files */ #define RLIMIT_TCACHE 8 /* maximum number of cached threads */ #define RLIM_NLIMITS 9 /* number of resource limits */ #endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */ #endif /* _SYS_RESOURCE_INCLUDED */ /* markd - No 3/14 code to merge. */ /* - No 3/24 code to merge. */