3

Possible Duplicate:
How to increase thread priority in pthreads?

I have a multithread code written in C++ using pthread. basically I have a main thread doing critical work and another thread doing maintenance. I'm wondering if there is a way to set a lower priority in the second thread so it runs when the first one is not busy?

Community
  • 1
  • 1
Daniel
  • 269
  • 4
  • 15
  • You can set priority for sure, but with multi-core systems the way they are today, I doubt you'd need to for such a simple example. – Michael Dorgan Dec 08 '11 at 18:33

1 Answers1

2

You can use pthread_setschedparam to set the priority of the thread

parapura rajkumar
  • 24,045
  • 1
  • 55
  • 85
  • Please avoid using references to "die" web site. It is outdated, bloated with ads, and appear as a first result only due to SEO. –  Dec 08 '11 at 18:58
  • thanks, I read the documents. looks like in user space I can use SCHED_BATCH or SCHED_IDLE to set a lower priority. I'm wondering what's the difference between the two? is it SCHED_OTHER > SCHED_BATCH > SCHED_IDLE? – Daniel Dec 08 '11 at 19:09