Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-08-19 07:34:17 +0300
committercjihrig <cjihrig@gmail.com>2018-08-23 00:27:16 +0300
commit92880f31da1eca98a42e0f61708b10d9d8d83955 (patch)
tree757a193b936f0a127b3445985ff688dd75ddab48 /doc/api/os.md
parent91eec00ca20a54b1dc010cfc2fb34bc2f39eab6b (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/api/os.md')
-rw-r--r--doc/api/os.md87
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>