How to measure flow and process time in Linux?

How to prioritize a thread and a process?

How in Linux to wait until all threads are executed (something like something like the WaitForMultipleObjects () function in WinApi)?

  • Making an algorithm, counting on a game with priorities, is not a good idea. - avp

1 answer 1

Priorities - pthread_setschedparam .

Analogue WaitForMultipleObjects - pthread_join .

  • as I understand it, pthread_join only works with one thread. or am i wrong? And if the threads are generated dynamically? Ie there is an array of threads. - nullptr
  • yes, with one. If you need to wait for several threads, then you can just wait for them in turn. will not escape anywhere. - KoVadim
  • possible, if you know how many of them. - nullptr
  • And you can make a semaphore. When threads start, they increase by one. When completed - reduce. All that business. - KoVadim
  • 2
    @nullptr, do you measure your streams? If so, take the time at the beginning of the function called in pthread_create and at the end of it. Either return the difference (take join) or put it where it is convenient. By the way, you probably know that join can be called (unlike fork) not only in the thread created by create? This can facilitate your task. You create a thread that picks up all those that have completed, selecting their thread_t from the queue (primitively from the pipe) into which they themselves put it before return. - avp