Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost: how to set program priority?

Tags:

c++

boost

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...

like image 774
Rella Avatar asked Feb 25 '23 16:02

Rella


2 Answers

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).

like image 177
timday Avatar answered Mar 08 '23 00:03

timday


Change boost thread priority in Windows

like image 20
Tom Avatar answered Mar 08 '23 00:03

Tom