home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / share / doc / ps1 / 06.sysman / 1.6.t < prev    next >
Encoding:
Text File  |  1991-04-17  |  5.1 KB  |  136 lines

  1. .\" Copyright (c) 1983 The Regents of the University of California.
  2. .\" All rights reserved.
  3. .\"
  4. .\" Redistribution and use in source and binary forms, with or without
  5. .\" modification, are permitted provided that the following conditions
  6. .\" are met:
  7. .\" 1. Redistributions of source code must retain the above copyright
  8. .\"    notice, this list of conditions and the following disclaimer.
  9. .\" 2. Redistributions in binary form must reproduce the above copyright
  10. .\"    notice, this list of conditions and the following disclaimer in the
  11. .\"    documentation and/or other materials provided with the distribution.
  12. .\" 3. All advertising materials mentioning features or use of this software
  13. .\"    must display the following acknowledgement:
  14. .\"    This product includes software developed by the University of
  15. .\"    California, Berkeley and its contributors.
  16. .\" 4. 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. .\"    @(#)1.6.t    6.3 (Berkeley) 4/17/91
  33. .\"
  34. .sh "Resource controls
  35. .NH 3
  36. Process priorities
  37. .PP
  38. The system gives CPU scheduling priority to processes that have not used
  39. CPU time recently.  This tends to favor interactive processes and
  40. processes that execute only for short periods.
  41. It is possible to determine the priority currently
  42. assigned to a process, process group, or the processes of a specified user,
  43. or to alter this priority using the calls:
  44. .DS
  45. ._d
  46. #define    PRIO_PROCESS    0    /* process */
  47. #define    PRIO_PGRP    1    /* process group */
  48. #define    PRIO_USER    2    /* user id */
  49.  
  50. prio = getpriority(which, who);
  51. result int prio; int which, who;
  52.  
  53. setpriority(which, who, prio);
  54. int which, who, prio;
  55. .DE
  56. The value \fIprio\fP is in the range \-20 to 20.
  57. The default priority is 0; lower priorities cause more
  58. favorable execution.
  59. The \fIgetpriority\fP call returns the highest priority (lowest numerical value)
  60. enjoyed by any of the specified processes.
  61. The \fIsetpriority\fP call sets the priorities of all of the
  62. specified processes to the specified value.
  63. Only the super-user may lower priorities.
  64. .NH 3
  65. Resource utilization
  66. .PP
  67. The resources used by a process are returned by a \fIgetrusage\fP call,
  68. returning information in a structure defined in \fI<sys/resource.h>\fP:
  69. .DS
  70. ._d
  71. #define    RUSAGE_SELF    0        /* usage by this process */
  72. #define    RUSAGE_CHILDREN    -1        /* usage by all children */
  73.  
  74. getrusage(who, rusage)
  75. int who; result struct rusage *rusage;
  76.  
  77. ._f
  78. struct rusage {
  79.     struct    timeval ru_utime;    /* user time used */
  80.     struct    timeval ru_stime;    /* system time used */
  81.     int    ru_maxrss;    /* maximum core resident set size: kbytes */
  82.     int    ru_ixrss;    /* integral shared memory size (kbytes*sec) */
  83.     int    ru_idrss;    /* unshared data memory size */
  84.     int    ru_isrss;    /* unshared stack memory size */
  85.     int    ru_minflt;    /* page-reclaims */
  86.     int    ru_majflt;    /* page faults */
  87.     int    ru_nswap;    /* swaps */
  88.     int    ru_inblock;    /* block input operations */
  89.     int    ru_oublock;    /* block output operations */
  90.     int    ru_msgsnd;    /* messages sent */
  91.     int    ru_msgrcv;    /* messages received */
  92.     int    ru_nsignals;    /* signals received */
  93.     int    ru_nvcsw;    /* voluntary context switches */
  94.     int    ru_nivcsw;    /* involuntary context switches */
  95. };
  96. .DE
  97. The \fIwho\fP parameter specifies whose resource usage is to be returned.
  98. The resources used by the current process, or by all
  99. the terminated children of the current process may be requested.
  100. .NH 3
  101. Resource limits
  102. .PP
  103. The resources of a process for which limits are controlled by the
  104. kernel are defined in \fI<sys/resource.h>\fP, and controlled by the
  105. \fIgetrlimit\fP and \fIsetrlimit\fP calls:
  106. .DS
  107. ._d
  108. #define    RLIMIT_CPU    0    /* cpu time in milliseconds */
  109. #define    RLIMIT_FSIZE    1    /* maximum file size */
  110. #define    RLIMIT_DATA    2    /* maximum data segment size */
  111. #define    RLIMIT_STACK    3    /* maximum stack segment size */
  112. #define    RLIMIT_CORE    4    /* maximum core file size */
  113. #define    RLIMIT_RSS    5    /* maximum resident set size */
  114.  
  115. #define    RLIM_NLIMITS    6
  116.  
  117. #define    RLIM_INFINITY    0x7f\&f\&f\&f\&f\&f\&f
  118.  
  119. ._f
  120. struct rlimit {
  121.     int    rlim_cur;    /* current (soft) limit */
  122.     int    rlim_max;    /* hard limit */
  123. };
  124.  
  125. getrlimit(resource, rlp)
  126. int resource; result struct rlimit *rlp;
  127.  
  128. setrlimit(resource, rlp)
  129. int resource; struct rlimit *rlp;
  130. .DE
  131. .PP
  132. Only the super-user can raise the maximum limits.
  133. Other users may only
  134. alter \fIrlim_cur\fP within the range from 0 to \fIrlim_max\fP
  135. or (irreversibly) lower \fIrlim_max\fP.
  136.