![]() |
VOOZH | about |
The os.setPriority() method is an inbuilt application programming interface of the os module which is used to set the scheduling priority of the process specified by pid and priority.
Syntax:
os.setPriority(pid, priority)
Parameters: This method has two parameters as mentioned above and described below:
Return Value: This method doesn't returns anything.
Note: As a priority in the Windows system is different from a UNIX system, the priority in the windows system is mapped into one of the six priority constants in os.constants.priority. So, while retrieving the value might be slightly different from the actual value. In the windows system, for setting the highest priority we need elevated users permission. so sometimes PRIORITY_HIGHEST may be changed to PRIORITY_HIGH without any warning.
Below examples illustrate the use of os.setPriority() method in Node.js:
Example 1:
Output:
setting priority for the current process to 17
Example 2:
Output:
10
Note: The above program will compile and run by using the node filename.js command.
Reference: https://nodejs.org/api/os.html#os_os_setpriority_pid_priority