LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Limiting CPU usage of a multithreaded process in Linux (https://www.linuxquestions.org/questions/linux-software-2/limiting-cpu-usage-of-a-multithreaded-process-in-linux-837544/)

reshika ag 10-12-2010 01:43 AM

Limiting CPU usage of a multithreaded process in Linux
 
Hi,
I have a multi-threaded process running and I have to limit the cpu time used by each of the threads. If 1 of the threads uses the whole of configured CPU time, the other thread should sleep and not consume CPU time in that cycle. 1 thread has higher preference over the other. How can i implement it my CPP code?

ozanbaba 10-12-2010 05:39 AM

Renice the thread, Which threading library do you use? Directly Pthread? Pthread library has several functions for changing priority of the threads (man pthread_setschedparam). However Linux will not allow you to change your thread to nicer to stop DOS attracts. But You can lower niceness of the less urgent one.


All times are GMT -5. The time now is 03:10 PM.