I want to lower the priority of a thread.
The default policy of my thread is SCHED_OTHER, and the range of priority under my system(Ubuntu) is [0,0] (I get the range by sched_get_priority_min(SCHED_OTHER) and sched_get_priority_max(SCHED_OTHER)) which means all threads with SCHED_OTHER will have the same priority.
Is there any approach to lower the priority with SCHED_OTHER? I've been searching for a while and I found the nice value system, but not sure if it's the correct way to do this, since the man page said nice value is for process, instead of thread, I'm confused...
Could anyone give the correct solution to do this, and maybe with a short code snippet? Thanks!
Added:
why I want to lower the priority of thread:
I have a worker thread, which is doing some intensive computation periodically (say, a few seconds every minute, thus will cause some CPU usage peak), and my whole system will experience periodically downgrade in performance. But the priority of this worker thread is low, as long as it can finish computation before next minute, it should be fine. so I want to amortize the computation of this task over this time window smoothly.
pthread_setschedparam