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