How to set program/thread priority (when talking about threads I mean ones that are created using Boost library) using Boost C++ library? I mean crossplatform way...
There's no generalised cross-platform priority support in boost itself.
#ifdef
is your friend...
See Tom's answer for the win32 solution.
On Linux you'd use the nice
call (or possibly setpriority
). Don't be put off by those document's statements that they adjust process priority; on Linux a thread is just a process which shares a memory space with some other process/processes. If you get yourself a better version of "top" which lists the individual threads, you can see the nice levels of each.
Note that a process/thread with normal user privileges can only reduce its priority (higher "nice" value) on Linux. The little bit of work with priorities I've done on Windows, it seemed anything goes (but that was on XP; situation may be different post-Vista, UAC etc).
Change boost thread priority in Windows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With