home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / resource / sys / resource.h next >
Encoding:
C/C++ Source or Header  |  1992-11-10  |  6.1 KB  |  176 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef    _SYS_RESOURCE_H
  20.  
  21. #define    _SYS_RESOURCE_H    1
  22. #include <features.h>
  23.  
  24. __BEGIN_DECLS
  25.  
  26.  
  27. /* Kinds of resource limit.  */
  28. enum __rlimit_resource
  29.   {
  30.     /* Per-process CPU limit, in seconds.  */
  31.     RLIMIT_CPU,
  32.     /* Largest file that can be created, in bytes.  */
  33.     RLIMIT_FSIZE,
  34.     /* Maximum size of data segment, in bytes.  */
  35.     RLIMIT_DATA,
  36.     /* Maximum size of stack segment, in bytes.  */
  37.     RLIMIT_STACK,
  38.     /* Largest core file that can be created, in bytes.  */
  39.     RLIMIT_CORE,
  40.     /* Largest resident set size, in bytes.
  41.        This affects swapping; processes that are exceeding their
  42.        resident set size will be more likely to have physical memory
  43.        taken from them.  */
  44.     RLIMIT_RSS,
  45.     /* Locked-in-memory address space.  */
  46.     RLIMIT_MEMLOCK,
  47.     /* Number of processes,  */
  48.     RLIMIT_NPROC,
  49.     /* Number of open files.  */
  50.     RLIMIT_OFILE,
  51.  
  52.     RLIM_NLIMITS
  53.     };
  54.  
  55. struct rlimit
  56.   {
  57.     /* The current (soft) limit.  */
  58.     int rlim_cur;
  59.     /* The hard limit.  */
  60.     int rlim_max;
  61.   };
  62.  
  63. /* Value used to indicate that there is no limit.  */
  64. #define RLIM_INFINITY 0x7fffffff
  65.  
  66. /* Put the soft and hard limits for RESOURCE in *RLIMITS.
  67.    Returns 0 if successful, -1 if not (and sets errno).  */
  68. int getrlimit __P ((enum __rlimit_resource __resource,
  69.             struct rlimit * __rlimits));
  70.  
  71. /* Set the soft and hard limits for RESOURCE to *RLIMITS.
  72.    Only the super-user can increase hard limits.
  73.    Return 0 if successful, -1 if not (and sets errno).  */
  74. int setrlimit __P ((enum __rlimit_resource __resource,
  75.             struct rlimit * __rlimits));
  76.  
  77.  
  78. /* Whose usage statistics do you want?  */
  79. enum __rusage_who
  80.   {
  81.     /* The calling process.  */
  82.     RUSAGE_SELF = 0,
  83.     /* All of its terminated child processes.  */
  84.     RUSAGE_CHILDREN = -1,
  85.   };
  86.  
  87. #include <sys/time.h>        /* For `struct timeval'.  */
  88.  
  89. /* Structure which says how much of each resource has been used.  */
  90. struct rusage
  91.   {
  92.     /* Total amount of user time used.  */
  93.     struct timeval ru_utime;
  94.     /* Total amount of system time used.  */
  95.     struct timeval ru_stime;
  96.     /* Maximum resident set size (in kilobytes).  */
  97.     int ru_maxrss;
  98.     /* Amount of sharing of text segment memory
  99.        with other processes (kilobyte-seconds).  */
  100.     int ru_ixrss;
  101.     /* Amount of data segment memory used (kilobyte-seconds).  */
  102.     int ru_idrss;
  103.     /* Amount of stack memory used (kilobyte-seconds).  */
  104.     int ru_isrss;
  105.     /* Number of soft page faults (i.e. those serviced by reclaiming
  106.        a page from the list of pages awaiting reallocation.  */
  107.     int ru_minflt;
  108.     /* Number of hard page faults (i.e. those that required I/O).  */
  109.     int ru_majflt;
  110.     /* Number of times a process was swapped out of physical memory.  */
  111.     int ru_nswap;
  112.     /* Number of input operations via the file system.  Note: This
  113.        and `ru_oublock' do not include operations with the cache.  */
  114.     int ru_inblock;
  115.     /* Number of output operations via the file system.  */
  116.     int ru_oublock;
  117.     /* Number of IPC messages sent.  */
  118.     int ru_msgsnd;
  119.     /* Number of IPC messages received.  */
  120.     int ru_msgrcv;
  121.     /* Number of signals delivered.  */
  122.     int ru_nsignals;
  123.     /* Number of voluntary context switches, i.e. because the process
  124.        gave up the process before it had to (usually to wait for some
  125.        resource to be available).  */
  126.     int ru_nvcsw;
  127.     /* Number of involuntary context switches, i.e. a higher priority process
  128.        became runnable or the current process used up its time slice.  */
  129.     int ru_nivcsw;
  130.   };
  131.  
  132. /* Return resource usage information on process indicated by WHO
  133.    and put it in *USAGE.  Returns 0 for success, -1 for failure.  */
  134. int __getrusage __P ((enum __rusage_who __who, struct rusage * __usage));
  135. int getrusage __P ((enum __rusage_who __who, struct rusage * __usage));
  136.  
  137. /* Function depends on CMD:
  138.    1 = Return the limit on the size of a file, in units of 512 bytes.
  139.    2 = Set the limit on the size of a file to NEWLIMIT.  Only the
  140.        super-user can increase the limit.
  141.    3 = Return the maximum possible address of the data segment.
  142.    4 = Return the maximum number of files that the calling process can open.
  143.    Returns -1 on errors.  */
  144. long int __ulimit __P ((int __cmd, long int __newlimit));
  145. long int ulimit __P ((int __cmd, long int __newlimit));
  146.  
  147.  
  148. /* Priority limits.  */
  149. #define    PRIO_MIN    -20    /* Minimum priority a process can have.  */
  150. #define    PRIO_MAX    20    /* Maximum priority a process can have.  */
  151.  
  152. /* The type of the WHICH argument to `getpriority' and `setpriority',
  153.    indicating what flavor of entity the WHO argument specifies.  */
  154. enum __priority_which
  155.   {
  156.     PRIO_PROCESS = 0,        /* WHO is a process ID.  */
  157.     PRIO_PGRP = 1,        /* WHO is a process group ID.  */
  158.     PRIO_USER = 2,        /* WHO is a user ID.  */
  159.   };
  160.  
  161. /* Return the highest priority of any process specified by WHICH and WHO
  162.    (see above); if WHO is zero, the current process, process group, or user
  163.    (as specified by WHO) is used.  A lower priority number means higher
  164.    priority.  Priorities range from PRIO_MIN to PRIO_MAX (above).  */
  165. extern int getpriority __P ((enum __priority_which __which, int __who));
  166.  
  167. /* Set the priority of all processes specified by WHICH and WHO (see above)
  168.    to PRIO.  Returns 0 on success, -1 on errors.  */
  169. extern int setpriority __P ((enum __priority_which __which, int __who,
  170.                  int __prio));
  171.  
  172.  
  173. __END_DECLS
  174.  
  175. #endif /* resource.h  */
  176.