Specify Process Priority #10
Comments
I would have to read up on this:
Feel free to do some research on this, I'm a bit swamped at the moment, and add relevant links if you'd like. |
Sure thing. Defaults:Linux: http://linux.die.net/man/2/setpriority Windows: Available settings:Linux: http://linux.die.net/man/1/renice Windows: Discussion:Due to the Linux restrictions on raising priority class, it's possible that setpriority might fail. I don't see any restrictions on Windows. This library could simply take an optimistic approach; attempt to change process priority and silently ignore errors, while documenting this possibility. Alternatively, return an error code or throw an exception. Standardizing priority values between platforms would need some thinking, as Linux priorities are more fine-grained than Windows priorities. Potentially you could define an enum with linux equivalents for the windows named priorities; eg NORMAL_PRIORITY_CLASS = 0, BELOW_NORMAL_PRIORITY_CLASS = 10, IDLE_PRIORITY_CLASS = PRIO_MAX. In the Windows impl, use the named values; in the *nix impl, use the underlying int values of that enum. I would also recommend a DEFAULT flag/enum so that the child process will default to the inherted priority class, which is the current behavior. Hope that helps/makes sense, let me know if I can assist further. Thank you |
Thanks for the excellent explanation! I'll have a look at this later this week. |
Hi, I'd like to specify a priority when launching a process. For example, I want to launch a background process with a lower process priority than the main process. As of right now, new processes are spawned with the default priority class and tiny process library does not give us the ability to control that.
On Windows, we provide a priority class flag in the 'dwCreationFlags' parameter to CreateProcess as specified here:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
I'm assuming *nix has a similar mechanism.
I could create a PR if you'd like; though the implementation seems fairly straight forward.
Thank you
Tom
The text was updated successfully, but these errors were encountered: