It took me a library of portable threads for C ++. Good people advised to look towards pthread. It turned out that in pthread there is no parameter "priority on which the thread is started".

In this regard, questions arise:

  1. What is the priority of running threads from pthread?
  2. Is there in nature a library of portable streams with the parameter "priority, on which the stream starts"?
  • 2
    (Offtopic: unnecessary words like “good afternoon” are considered garbage and are not approved . Editing a comment is limited to five minutes in order to exclude the editing completely changing the meaning of the comment, after which the answers to this comment start to look silly.) - VladD
  • 2
    And the effect you described looks very strange. The interpreter runs in the next thread and does not affect the execution of other threads. Is that he eats 100% processor resources. Something is wrong here, you are not digging there. In my practice, the neighboring stream never working at full capacity blocked the UI. - VladD
  • one
    So the problem is not what you describe. For the scheduler there is no difference what kind of thread to launch - yours or someone else's application. I bet you have an error in synchronization between threads. - VladD
  • 2
    In my opinion, the fact that inserting Sleep 's, lowering priority, and similar games improves the result is just an error in synchronization. And how do you explain that the interpreter strangely interferes only with your UI thread, and not with other threads in the system? - VladD
  • one
    But on multi-core with two threads working, they can not interfere with each other (if they are not connected by code) - Lol4t0

1 answer 1

Cross-platform threads are std::thread . Since when did pthreads become “portable”, it's not clear to me, pthread is p [OSIX] thread. You cannot set a priority using std::thread , but you can get std::thread::native_handle , which you can work with later using the API of one or another OS.

I am not familiar with Linux, but a quick inspection showed that, as such, the concept of priority is not there, so it’s impossible to talk about a cross-platform solution of priority change. Linux has niceness, but how to unify this value with priorities from Windows is not clear. Therefore, it is very likely that no one became involved in cross-platform implementation of the functional, which is necessary for a couple of percent of all software.

  • one
    There are thread priorities in linux, only in most cases they are not needed - sercxjo
  • one
    @sercxjo: Exactly. The need to manage thread priorities is a sign of an error in the design of the program. - VladD
  • Why is it a sign of a mistake? If the library flow is working on some priority, then you should be able to move your thread on priorities. - pepsicoca1
  • @VladD, most likely, probably - yes. But not always. Software is different and the requirements too. - ixSci