|
|
1.1 ! root 1: .\" Copyright (c) 1983 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)1.6.t 6.2 (Berkeley) 5/12/86 ! 6: .\" ! 7: .sh "Resource controls ! 8: .NH 3 ! 9: Process priorities ! 10: .PP ! 11: The system gives CPU scheduling priority to processes that have not used ! 12: CPU time recently. This tends to favor interactive processes and ! 13: processes that execute only for short periods. ! 14: It is possible to determine the priority currently ! 15: assigned to a process, process group, or the processes of a specified user, ! 16: or to alter this priority using the calls: ! 17: .DS ! 18: ._d ! 19: #define PRIO_PROCESS 0 /* process */ ! 20: #define PRIO_PGRP 1 /* process group */ ! 21: #define PRIO_USER 2 /* user id */ ! 22: ! 23: prio = getpriority(which, who); ! 24: result int prio; int which, who; ! 25: ! 26: setpriority(which, who, prio); ! 27: int which, who, prio; ! 28: .DE ! 29: The value \fIprio\fP is in the range \-20 to 20. ! 30: The default priority is 0; lower priorities cause more ! 31: favorable execution. ! 32: The \fIgetpriority\fP call returns the highest priority (lowest numerical value) ! 33: enjoyed by any of the specified processes. ! 34: The \fIsetpriority\fP call sets the priorities of all of the ! 35: specified processes to the specified value. ! 36: Only the super-user may lower priorities. ! 37: .NH 3 ! 38: Resource utilization ! 39: .PP ! 40: The resources used by a process are returned by a \fIgetrusage\fP call, ! 41: returning information in a structure defined in \fI<sys/resource.h>\fP: ! 42: .DS ! 43: ._d ! 44: #define RUSAGE_SELF 0 /* usage by this process */ ! 45: #define RUSAGE_CHILDREN -1 /* usage by all children */ ! 46: ! 47: getrusage(who, rusage) ! 48: int who; result struct rusage *rusage; ! 49: ! 50: ._f ! 51: struct rusage { ! 52: struct timeval ru_utime; /* user time used */ ! 53: struct timeval ru_stime; /* system time used */ ! 54: int ru_maxrss; /* maximum core resident set size: kbytes */ ! 55: int ru_ixrss; /* integral shared memory size (kbytes*sec) */ ! 56: int ru_idrss; /* unshared data memory size */ ! 57: int ru_isrss; /* unshared stack memory size */ ! 58: int ru_minflt; /* page-reclaims */ ! 59: int ru_majflt; /* page faults */ ! 60: int ru_nswap; /* swaps */ ! 61: int ru_inblock; /* block input operations */ ! 62: int ru_oublock; /* block output operations */ ! 63: int ru_msgsnd; /* messages sent */ ! 64: int ru_msgrcv; /* messages received */ ! 65: int ru_nsignals; /* signals received */ ! 66: int ru_nvcsw; /* voluntary context switches */ ! 67: int ru_nivcsw; /* involuntary context switches */ ! 68: }; ! 69: .DE ! 70: The \fIwho\fP parameter specifies whose resource usage is to be returned. ! 71: The resources used by the current process, or by all ! 72: the terminated children of the current process may be requested. ! 73: .NH 3 ! 74: Resource limits ! 75: .PP ! 76: The resources of a process for which limits are controlled by the ! 77: kernel are defined in \fI<sys/resource.h>\fP, and controlled by the ! 78: \fIgetrlimit\fP and \fIsetrlimit\fP calls: ! 79: .DS ! 80: ._d ! 81: #define RLIMIT_CPU 0 /* cpu time in milliseconds */ ! 82: #define RLIMIT_FSIZE 1 /* maximum file size */ ! 83: #define RLIMIT_DATA 2 /* maximum data segment size */ ! 84: #define RLIMIT_STACK 3 /* maximum stack segment size */ ! 85: #define RLIMIT_CORE 4 /* maximum core file size */ ! 86: #define RLIMIT_RSS 5 /* maximum resident set size */ ! 87: ! 88: #define RLIM_NLIMITS 6 ! 89: ! 90: #define RLIM_INFINITY 0x7f\&f\&f\&f\&f\&f\&f ! 91: ! 92: ._f ! 93: struct rlimit { ! 94: int rlim_cur; /* current (soft) limit */ ! 95: int rlim_max; /* hard limit */ ! 96: }; ! 97: ! 98: getrlimit(resource, rlp) ! 99: int resource; result struct rlimit *rlp; ! 100: ! 101: setrlimit(resource, rlp) ! 102: int resource; struct rlimit *rlp; ! 103: .DE ! 104: .PP ! 105: Only the super-user can raise the maximum limits. ! 106: Other users may only ! 107: alter \fIrlim_cur\fP within the range from 0 to \fIrlim_max\fP ! 108: or (irreversibly) lower \fIrlim_max\fP.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.