QThread set scheduling policy
Is it possible to set scheduling policy in Qthread ?
Im using ubuntu, and I'm confident that qthreads are implemented using pthreads, but I don't know how to acces pthreads attribs for advanced tuning like setting scheduling policy.
With posix classes I would use:
Code:
#include <pthread.h>
pthread_attr_t attrib;
pthread_attr_init(&attrib);
int ret = pthread_attr_setschedpolicy(&attrib, SCHED_RR);
but I don't figure out how to do this with Qthreads.
Re: QThread set scheduling policy
You will have to patch Qt, more precisely QThread::start() in corelib/thread/qthread_unix.cpp
Cheers,
_
Re: QThread set scheduling policy
thanks for the advice, although I'm in doubt about this: I wonder how to expose in QThread attrib struct. The regular way should be to provide an accessor to internal data. If I modify the start() call, I I have to pass as argument the attribs struct address, and inside the method start() i should manipulate the scheduler, that isn't correct from the encapsulation point of view. Isn't it?
So, after this brainstorming, I can reformulate my question to you: how to modify qthread sources (POSIX part) in order to encapsulate the scheduling policies?
Re: QThread set scheduling policy
Hmm, you could add another enum.
Cheers,
_