diff options
author | cjihrig <cjihrig@gmail.com> | 2018-08-19 07:34:17 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2018-09-03 18:56:53 +0300 |
commit | 219da67e2eff0a330566050741fe221856586f13 (patch) | |
tree | ce0b253cdd64006fcec7f82e7b0ca73dc35bb667 /doc | |
parent | 5b14066c14e3a6719829ceef1471b5cd5b33da41 (diff) |
os: add os.{get,set}Priority()
PR-URL: https://github.com/nodejs/node/pull/22407
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/os.md | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/doc/api/os.md b/doc/api/os.md index b7bd246f97d..4557bb6b7d3 100644 --- a/doc/api/os.md +++ b/doc/api/os.md @@ -192,6 +192,19 @@ added: v0.3.3 The `os.freemem()` method returns the amount of free system memory in bytes as an integer. +## os.getPriority([pid]) +<!-- YAML +added: REPLACEME +--> + +* `pid` {integer} The process ID to retrieve scheduling priority for. + **Default** `0`. +* Returns: {integer} + +The `os.getPriority()` method returns the scheduling priority for the process +specified by `pid`. If `pid` is not provided, or is `0`, the priority of the +current process is returned. + ## os.homedir() <!-- YAML added: v2.3.0 @@ -338,6 +351,26 @@ On POSIX systems, the operating system release is determined by calling [uname(3)][]. On Windows, `GetVersionExW()` is used. Please see https://en.wikipedia.org/wiki/Uname#Examples for more information. +## os.setPriority([pid, ]priority) +<!-- YAML +added: REPLACEME +--> + +* `pid` {integer} The process ID to set scheduling priority for. + **Default** `0`. +* `priority` {integer} The scheduling priority to assign to the process. + +The `os.setPriority()` method attempts to set the scheduling priority for the +process specified by `pid`. If `pid` is not provided, or is `0`, the priority +of the current process is used. + +The `priority` input must be an integer between `-20` (high priority) and `19` +(low priority). Due to differences between Unix priority levels and Windows +priority classes, `priority` is mapped to one of six priority constants in +`os.constants.priority`. When retrieving a process priority level, this range +mapping may cause the return value to be slightly different on Windows. To avoid +confusion, it is recommended to set `priority` to one of the priority constants. + ## os.tmpdir() <!-- YAML added: v0.9.9 @@ -1208,6 +1241,60 @@ information. </tr> </table> +### Priority Constants +<!-- YAML +added: REPLACEME +--> + +The following process scheduling constants are exported by +`os.constants.priority`: + +<table> + <tr> + <th>Constant</th> + <th>Description</th> + </tr> + <tr> + <td><code>PRIORITY_LOW</code></td> + <td>The lowest process scheduling priority. This corresponds to + <code>IDLE_PRIORITY_CLASS</code> on Windows, and a nice value of + <code>19</code> on all other platforms.</td> + </tr> + <tr> + <td><code>PRIORITY_BELOW_NORMAL</code></td> + <td>The process scheduling priority above <code>PRIORITY_LOW</code> and + below <code>PRIORITY_NORMAL</code>. This corresponds to + <code>BELOW_NORMAL_PRIORITY_CLASS</code> on Windows, and a nice value of + <code>10</code> on all other platforms.</td> + </tr> + <tr> + <td><code>PRIORITY_NORMAL</code></td> + <td>The default process scheduling priority. This corresponds to + <code>NORMAL_PRIORITY_CLASS</code> on Windows, and a nice value of + <code>0</code> on all other platforms.</td> + </tr> + <tr> + <td><code>PRIORITY_ABOVE_NORMAL</code></td> + <td>The process scheduling priority above <code>PRIORITY_NORMAL</code> and + below <code>PRIORITY_HIGH</code>. This corresponds to + <code>ABOVE_NORMAL_PRIORITY_CLASS</code> on Windows, and a nice value of + <code>-7</code> on all other platforms.</td> + </tr> + <tr> + <td><code>PRIORITY_HIGH</code></td> + <td>The process scheduling priority above <code>PRIORITY_ABOVE_NORMAL</code> + and below <code>PRIORITY_HIGHEST</code>. This corresponds to + <code>HIGH_PRIORITY_CLASS</code> on Windows, and a nice value of + <code>-14</code> on all other platforms.</td> + </tr> + <tr> + <td><code>PRIORITY_HIGHEST</code></td> + <td>The highest process scheduling priority. This corresponds to + <code>REALTIME_PRIORITY_CLASS</code> on Windows, and a nice value of + <code>-20</code> on all other platforms.</td> + </tr> +</table> + ### libuv Constants <table> |