logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

getpriority.3p (6150B)


  1. '\" et
  2. .TH GETPRIORITY "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. getpriority,
  12. setpriority
  13. \(em get and set the nice value
  14. .SH SYNOPSIS
  15. .LP
  16. .nf
  17. #include <sys/resource.h>
  18. .P
  19. int getpriority(int \fIwhich\fP, id_t \fIwho\fP);
  20. int setpriority(int \fIwhich\fP, id_t \fIwho\fP, int \fIvalue\fP);
  21. .fi
  22. .SH DESCRIPTION
  23. The
  24. \fIgetpriority\fR()
  25. function shall obtain the nice value of a process, process group, or
  26. user. The
  27. \fIsetpriority\fR()
  28. function shall set the nice value of a process, process group, or user
  29. to
  30. .IR value +\c
  31. {NZERO}.
  32. .P
  33. Target processes are specified by the values of the
  34. .IR which
  35. and
  36. .IR who
  37. arguments. The
  38. .IR which
  39. argument may be one of the following values: PRIO_PROCESS, PRIO_PGRP,
  40. or PRIO_USER, indicating that the
  41. .IR who
  42. argument
  43. is to be interpreted as a process ID, a process group ID, or an
  44. effective user ID, respectively. A 0 value for the
  45. .IR who
  46. argument specifies the current process, process group, or user.
  47. .P
  48. The nice value set with
  49. \fIsetpriority\fR()
  50. shall be applied to the process. If the process is multi-threaded,
  51. the nice value shall affect all system scope threads in the process.
  52. .P
  53. If more than one process is specified,
  54. \fIgetpriority\fR()
  55. shall return value
  56. {NZERO}
  57. less than the lowest nice value pertaining to any of the specified
  58. processes, and
  59. \fIsetpriority\fR()
  60. shall set the nice values of all of the specified processes to
  61. .IR value +\c
  62. {NZERO}.
  63. .P
  64. The default nice value is
  65. {NZERO};
  66. lower nice values shall cause more favorable scheduling. While the
  67. range of valid nice values is [0,{NZERO}*2\-1], implementations may
  68. enforce more restrictive limits. If
  69. .IR value +\c
  70. {NZERO}
  71. is less than the system's lowest supported nice value,
  72. \fIsetpriority\fR()
  73. shall set the nice value to the lowest supported value; if
  74. .IR value +\c
  75. {NZERO}
  76. is greater than the system's highest supported nice value,
  77. \fIsetpriority\fR()
  78. shall set the nice value to the highest supported value.
  79. .P
  80. Only a process with appropriate privileges can lower its nice value.
  81. .P
  82. Any processes or threads using SCHED_FIFO or SCHED_RR shall be
  83. unaffected by a call to
  84. \fIsetpriority\fR().
  85. This is not considered an error. A process which subsequently reverts
  86. to SCHED_OTHER need not have its priority affected by such a
  87. \fIsetpriority\fR()
  88. call.
  89. .P
  90. The effect of changing the nice value may vary depending on the
  91. process-scheduling algorithm in effect.
  92. .P
  93. Since
  94. \fIgetpriority\fR()
  95. can return the value \-1 upon successful completion, it is necessary to
  96. set
  97. .IR errno
  98. to 0 prior to a call to
  99. \fIgetpriority\fR().
  100. If
  101. \fIgetpriority\fR()
  102. returns the value \-1, then
  103. .IR errno
  104. can be checked to see if an error occurred or if the value is a
  105. legitimate nice value.
  106. .SH "RETURN VALUE"
  107. Upon successful completion,
  108. \fIgetpriority\fR()
  109. shall return an integer in the range \-{NZERO} to
  110. {NZERO}\-1.
  111. Otherwise, \-1 shall be returned and
  112. .IR errno
  113. set to indicate the error.
  114. .P
  115. Upon successful completion,
  116. \fIsetpriority\fR()
  117. shall return 0; otherwise, \-1 shall be returned and
  118. .IR errno
  119. set to indicate the error.
  120. .br
  121. .SH ERRORS
  122. The
  123. \fIgetpriority\fR()
  124. and
  125. \fIsetpriority\fR()
  126. functions shall fail if:
  127. .TP
  128. .BR ESRCH
  129. No process could be located using the
  130. .IR which
  131. and
  132. .IR who
  133. argument values specified.
  134. .TP
  135. .BR EINVAL
  136. The value of the
  137. .IR which
  138. argument was not recognized, or the value of the
  139. .IR who
  140. argument is not a valid process ID, process group ID, or user ID.
  141. .P
  142. In addition,
  143. \fIsetpriority\fR()
  144. may fail if:
  145. .TP
  146. .BR EPERM
  147. A process was located, but neither the real nor effective user ID of
  148. the executing process match the effective user ID of the process whose
  149. nice value is being changed.
  150. .TP
  151. .BR EACCES
  152. A request was made to change the nice value to a lower numeric value
  153. and the current process does not have appropriate privileges.
  154. .LP
  155. .IR "The following sections are informative."
  156. .SH EXAMPLES
  157. .SS "Using getpriority(\|)"
  158. .P
  159. The following example returns the current scheduling priority for the
  160. process ID returned by the call to
  161. \fIgetpid\fR().
  162. .sp
  163. .RS 4
  164. .nf
  165. #include <sys/resource.h>
  166. \&...
  167. int which = PRIO_PROCESS;
  168. id_t pid;
  169. int ret;
  170. .P
  171. pid = getpid();
  172. ret = getpriority(which, pid);
  173. .fi
  174. .P
  175. .RE
  176. .SS "Using setpriority(\|)"
  177. .P
  178. The following example sets the priority for the current process ID to
  179. \-20.
  180. .sp
  181. .RS 4
  182. .nf
  183. #include <sys/resource.h>
  184. \&...
  185. int which = PRIO_PROCESS;
  186. id_t pid;
  187. int priority = -20;
  188. int ret;
  189. .P
  190. pid = getpid();
  191. ret = setpriority(which, pid, priority);
  192. .fi
  193. .P
  194. .RE
  195. .SH "APPLICATION USAGE"
  196. The
  197. \fIgetpriority\fR()
  198. and
  199. \fIsetpriority\fR()
  200. functions work with an offset nice value (nice value \-{NZERO}). The
  201. nice value is in the range [0,2*{NZERO} \-1], while the return value
  202. for
  203. \fIgetpriority\fR()
  204. and the third parameter for
  205. \fIsetpriority\fR()
  206. are in the range [\-{NZERO},{NZERO} \-1].
  207. .SH RATIONALE
  208. None.
  209. .SH "FUTURE DIRECTIONS"
  210. None.
  211. .SH "SEE ALSO"
  212. .IR "\fInice\fR\^(\|)",
  213. .IR "\fIsched_get_priority_max\fR\^(\|)",
  214. .IR "\fIsched_setscheduler\fR\^(\|)"
  215. .P
  216. The Base Definitions volume of POSIX.1\(hy2017,
  217. .IR "\fB<sys_resource.h>\fP"
  218. .\"
  219. .SH COPYRIGHT
  220. Portions of this text are reprinted and reproduced in electronic form
  221. from IEEE Std 1003.1-2017, Standard for Information Technology
  222. -- Portable Operating System Interface (POSIX), The Open Group Base
  223. Specifications Issue 7, 2018 Edition,
  224. Copyright (C) 2018 by the Institute of
  225. Electrical and Electronics Engineers, Inc and The Open Group.
  226. In the event of any discrepancy between this version and the original IEEE and
  227. The Open Group Standard, the original IEEE and The Open Group Standard
  228. is the referee document. The original Standard can be obtained online at
  229. http://www.opengroup.org/unix/online.html .
  230. .PP
  231. Any typographical or formatting errors that appear
  232. in this page are most likely
  233. to have been introduced during the conversion of the source files to
  234. man page format. To report such errors, see
  235. https://www.kernel.org/doc/man-pages/reporting_bugs.html .